<commit_before>'use strict';

/**
 * Unit tests for octopus-deploy.js
 */
var expect = require('chai').expect;
var BPromise = require('bluebird');

var testConfig = require('./etc/test-config');
var OctoDeployApi = require('../lib/octopus-deploy');
var mockDeployment = require('./mocks/mock-deployment.json');

var client = new OctoDeployApi(testConfig);

var sandbox;
var octoRequestGet;
var octoRequestPost;

var internals = {};

describe('deployments', function () {

	beforeEach(function (done) {

		sandbox = require('sinon').sandbox.create();
		octoRequestGet = sandbox.stub(require('request-promise'), 'get', function (options) {

			return BPromise.resolve(mockDeployment);
		});
		octoRequestPost = sandbox.stub(require('request-promise'), 'post', function (options) {

			return BPromise.resolve(mockDeployment);
		});
		done();
	});

	afterEach(function (done) {
		sandbox.restore();
		done();
	});


	describe('findById', function () {

		it('should find a deployment', function () {

			var deploymentId = 'deployments-123';

			return client.deployment.findById(deploymentId)
				.then(function (deployment) {
					internals.validateDeploymentObject(deployment);
				});
		});
	});

});

internals.validateDeploymentObject = function (deployment) {
<commit_msg>third pass with release and deploy, still need to finish simplified release and deploy<commit_after>'use strict';

/**
 * Unit tests for octopus-deploy.js
 */
var expect = require('chai').expect;
var BPromise = require('bluebird');

var testConfig = require('./etc/test-config');
var OctoDeployApi = require('../lib/octopus-deploy');
var mockDeployment = require('./mocks/mock-deployment.json');

var client = new OctoDeployApi(testConfig);

var sandbox;
var octoRequestGet;
var octoRequestPost;

var internals = {};

describe('deployments', function () {

	beforeEach(function (done) {

		sandbox = require('sinon').sandbox.create();
		octoRequestGet = sandbox.stub(require('request-promise'), 'get', function (options) {

			return BPromise.resolve(mockDeployment);
		});
		octoRequestPost = sandbox.stub(require('request-promise'), 'post', function (options) {

			return BPromise.resolve(mockDeployment);
		});
		done();
	});

	afterEach(function (done) {
		sandbox.restore();
		done();
	});


	describe('findById', function () {

		it('should find a deployment', function () {

			var deploymentId = 'deployments-123';

			return client.deployment.findById(deploymentId)
				.then(function (deployment) {
					internals.validateDeploymentObject(deployment);
				});
		});
	});

	describe('create', function () {

		it('should create a deployment', function () {

			var environmentId = 'Environments-123';
			var releaseId = 'releases-123';
			var comments = 'Deploy releases-123 to DEVSERVER1';
			// Form Value Example: Source Directory
			// The formValues.attribute is unique id for the 'SourceDir' variable
			var formValues = {
				'd02ff723-7fdb-2011-792d-ad99eaa3e1cc': '\\\\SOURCESERVER\\MyProject\\1.0.0-rc-3'
			};

			return client.deployment.create(environmentId, releaseId, comments, formValues)
				.then(function (deployment) {
					internals.validateDeploymentObject(deployment);
				});
		});
	});

});

internals.validateDeploymentObject = function (deployment) {

{'fraction_non_alphanumeric': 0.15196078431372548, 'fraction_numerical': 0.01133578431372549, 'mean_word_length': 4.552721088435374, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1324319', 'n_tokens_mistral': 1158, 'n_tokens_neox': 1005, 'n_words': 210}