Skip to content

Commit 44b464e

Browse files
mmercesdesimone
authored andcommitted
Splitting tests and enlarging travis timeout
1 parent d17743f commit 44b464e

6 files changed

+539
-822
lines changed

.travis.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
language: php
22
env:
3-
- BML_TESTS="05_a"
3+
- BML_TESTS="05_a 05_c"
44
- BML_TESTS="05_b"
55
- BML_TESTS="01 03 04 06 07"
6-
- BML_TESTS="08 09 10 11 12 36"
7-
- BML_TESTS="32"
6+
- BML_TESTS="08 09 10 11 12 36_a 36_b"
7+
- BML_TESTS="32_a 32_b"
88
- BML_TESTS="13 14 15 16 17 18 19 20"
99
- BML_TESTS="21 22 24 25 26 27 28 29 30 31"
1010
- BML_TESTS="23 38"

tests/test_05_a_compare_predictions.php

-387
Large diffs are not rendered by default.

tests/test_05_c_compare_predictions.php

+444
Large diffs are not rendered by default.

tests/test_32_topic_model_prediction.php renamed to tests/test_32_a_topic_model_prediction.php

-51
Original file line numberDiff line numberDiff line change
@@ -97,56 +97,5 @@ public function test_scenario1() {
9797
$this->assertEquals($distribution, $item["expected"]);
9898
}
9999
}
100-
101-
public function testscenerio2() {
102-
103-
$data = array(array("filename" => 'data/spam.csv',
104-
"topic_model_name" => 'my new topic model name',
105-
"params" => array("fields"=>
106-
array("000001"=>
107-
array("optype"=> "text",
108-
"term_analysis"=> array("case_sensitive" => true,
109-
"stem_words" => true,
110-
"use_stopwords" => false,
111-
"language" => "en"))))));
112-
113-
foreach($data as $item) {
114-
print "\nGiven I create a data source uploading a data file\n";
115-
$source = self::$api->create_source($item["filename"], $options=array('name'=>'local_test_source', 'project'=> self::$project->resource));
116-
$this->assertEquals(BigMLRequest::HTTP_CREATED, $source->code);
117-
$this->assertEquals(1, $source->object->status->code);
118-
119-
print "And I wait until the source is ready\n";
120-
$resource = self::$api->_check_resource($source->resource, null, 3000, 30);
121-
$this->assertEquals(BigMLRequest::FINISHED, $resource["status"]);
122-
123-
print "And I update the source\n";
124-
$updated_source = self::$api->update_source($source->resource, $item["params"], 3000, 30);
125-
126-
print "And I create a dataset\n";
127-
$dataset = self::$api->create_dataset($updated_source->resource);
128-
$this->assertEquals(BigMLRequest::HTTP_CREATED, $dataset->code);
129-
$this->assertEquals(BigMLRequest::QUEUED, $dataset->object->status->code);
130-
131-
print "And I wait until the dataset is ready\n";
132-
$resource = self::$api->_check_resource($dataset->resource, null, 3000, 30);
133-
$this->assertEquals(BigMLRequest::FINISHED, $resource["status"]);
134-
135-
print "And I create topic model from a dataset\n";
136-
$topicmodel = self::$api->create_topicmodel($dataset->resource);
137-
$this->assertEquals(BigMLRequest::HTTP_CREATED, $topicmodel->code);
138-
139-
print "And I wait until the topic model is ready\n";
140-
$resource = self::$api->_check_resource($topicmodel->resource, null, 3000, 50);
141-
$this->assertEquals(BigMLRequest::FINISHED, $resource["status"]);
142-
143-
print "And I update the topic model name to " . $item["topic_model_name"] . "\n";
144-
$updated_topicmodel = self::$api->update_topicmodel($topicmodel->resource, array("name" => $item["topic_model_name"]));
145-
146-
print "Then the topic model name is " . $item["topic_model_name"] . "\n";
147-
$new_topicmodel=self::$api->get_topicmodel($updated_topicmodel->resource);
148-
$this->assertEquals($new_topicmodel->object->name, $item["topic_model_name"]);
149-
}
150-
}
151100
}
152101
?>
+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<?php
2+
3+
include 'test_utils.php';
4+
5+
//importing
6+
if (!class_exists('BigML\BigML')) {
7+
include '../bigml/bigml.php';
8+
}
9+
10+
if (!class_exists('BigML\TopicModel')) {
11+
include '../bigml/topicmodel.php';
12+
}
13+
14+
use BigML\BigML;
15+
use BigML\BigMLRequest;
16+
use BigML\TopicModel;
17+
18+
class BigMLTestBoostedEnsemble extends PHPUnit_Framework_TestCase
19+
{
20+
protected static $username; # "you_username"
21+
protected static $api_key; # "your_api_key"
22+
protected static $api;
23+
protected static $project;
24+
25+
public static function setUpBeforeClass() {
26+
print __FILE__;
27+
self::$api = new BigML(self::$username, self::$api_key, false);
28+
ini_set('memory_limit', '512M');
29+
$test_name=basename(preg_replace('/\.php$/', '', __FILE__));
30+
self::$api->delete_all_project_by_name($test_name);
31+
self::$project=self::$api->create_project(array('name'=> $test_name));
32+
}
33+
34+
public static function tearDownAfterClass() {
35+
self::$api->delete_all_project_by_name(basename(preg_replace('/\.php$/', '', __FILE__)));
36+
}
37+
38+
// Successfully creating a distribution from a Topic Model
39+
40+
41+
public function test_scenario2() {
42+
43+
$data = array(array("filename" => 'data/spam.csv',
44+
"topic_model_name" => 'my new topic model name',
45+
"params" => array("fields"=>
46+
array("000001"=>
47+
array("optype"=> "text",
48+
"term_analysis"=> array("case_sensitive" => true,
49+
"stem_words" => true,
50+
"use_stopwords" => false,
51+
"language" => "en"))))));
52+
53+
foreach($data as $item) {
54+
print "\nGiven I create a data source uploading a data file\n";
55+
$source = self::$api->create_source($item["filename"], $options=array('name'=>'local_test_source', 'project'=> self::$project->resource));
56+
$this->assertEquals(BigMLRequest::HTTP_CREATED, $source->code);
57+
$this->assertEquals(1, $source->object->status->code);
58+
59+
print "And I wait until the source is ready\n";
60+
$resource = self::$api->_check_resource($source->resource, null, 3000, 30);
61+
$this->assertEquals(BigMLRequest::FINISHED, $resource["status"]);
62+
63+
print "And I update the source\n";
64+
$updated_source = self::$api->update_source($source->resource, $item["params"], 3000, 30);
65+
66+
print "And I create a dataset\n";
67+
$dataset = self::$api->create_dataset($updated_source->resource);
68+
$this->assertEquals(BigMLRequest::HTTP_CREATED, $dataset->code);
69+
$this->assertEquals(BigMLRequest::QUEUED, $dataset->object->status->code);
70+
71+
print "And I wait until the dataset is ready\n";
72+
$resource = self::$api->_check_resource($dataset->resource, null, 3000, 30);
73+
$this->assertEquals(BigMLRequest::FINISHED, $resource["status"]);
74+
75+
print "And I create topic model from a dataset\n";
76+
$topicmodel = self::$api->create_topicmodel($dataset->resource);
77+
$this->assertEquals(BigMLRequest::HTTP_CREATED, $topicmodel->code);
78+
79+
print "And I wait until the topic model is ready\n";
80+
$resource = self::$api->_check_resource($topicmodel->resource, null, 3000, 50);
81+
$this->assertEquals(BigMLRequest::FINISHED, $resource["status"]);
82+
83+
print "And I update the topic model name to " . $item["topic_model_name"] . "\n";
84+
$updated_topicmodel = self::$api->update_topicmodel($topicmodel->resource, array("name" => $item["topic_model_name"]));
85+
86+
print "Then the topic model name is " . $item["topic_model_name"] . "\n";
87+
$new_topicmodel=self::$api->get_topicmodel($updated_topicmodel->resource);
88+
$this->assertEquals($new_topicmodel->object->name, $item["topic_model_name"]);
89+
}
90+
}
91+
}
92+
?>

0 commit comments

Comments
 (0)