本文整理汇总了Python中tests.factories.TeamFactory.add_projects方法的典型用法代码示例。如果您正苦于以下问题:Python TeamFactory.add_projects方法的具体用法?Python TeamFactory.add_projects怎么用?Python TeamFactory.add_projects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tests.factories.TeamFactory
的用法示例。
在下文中一共展示了TeamFactory.add_projects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_delete_a_project
# 需要导入模块: from tests.factories import TeamFactory [as 别名]
# 或者: from tests.factories.TeamFactory import add_projects [as 别名]
def test_delete_a_project(self):
team = TeamFactory.create()
TeamFactory.add_projects(team, 1)
project = team.projects[0]
team.delete_project(project.name)
retrieved = Team.objects.filter(name=team.name).first()
expect(retrieved.projects).to_length(0)
示例2: test_can_run_funkload
# 需要导入模块: from tests.factories import TeamFactory [as 别名]
# 或者: from tests.factories.TeamFactory import add_projects [as 别名]
def test_can_run_funkload(self):
team = TeamFactory.create()
TeamFactory.add_projects(team, 1)
user = team.owner
project = team.projects[0]
load_test = LoadTestFactory.add_to_project(1, user=user, team=team, project=project)
load_test.pressure = "small"
conf = WightConfig.load(join(root_path, 'bench', 'wight.yml'))
test = conf.tests[0]
DEFAULT_CYCLES = {
"small": [10, 20],
"medium": [10, 20, 30],
"large": [30, 75, 100],
}
fl_result = FunkLoadBenchRunner.run(root_path, test, self.base_url, cycles=DEFAULT_CYCLES, duration=5)
expect(fl_result).not_to_be_null()
expect(fl_result.exit_code).to_equal(0)
expect(fl_result.text).to_include("SUCCESSFUL")
expect(fl_result.log).to_be_empty()
expect(fl_result.result).not_to_be_null()
expect(fl_result.config).not_to_be_null()
result = LoadTest.get_data_from_funkload_results(fl_result.config, fl_result.result)
load_test.add_result(result, fl_result.text)
expect(load_test.results).to_length(1)
示例3: setUp
# 需要导入模块: from tests.factories import TeamFactory [as 别名]
# 或者: from tests.factories.TeamFactory import add_projects [as 别名]
def setUp(self):
super(DeleteTeamProjectTest, self).setUp()
self.user = UserFactory.create(with_token=True)
self.team = TeamFactory.create(owner=self.user)
TeamFactory.add_projects(self.team, 1)
TeamFactory.add_members(self.team, 2)
self.project = self.team.projects[0]
示例4: test_update_a_project_with_name
# 需要导入模块: from tests.factories import TeamFactory [as 别名]
# 或者: from tests.factories.TeamFactory import add_projects [as 别名]
def test_update_a_project_with_name(self):
team = TeamFactory.create()
TeamFactory.add_projects(team, 1)
project = team.projects[0]
team.update_project(project.name, "new-name")
retrieved = Team.objects.filter(name=team.name).first()
expect(retrieved.projects[0].name).to_equal("new-name")
expect(retrieved.projects[0].repository).to_equal(project.repository)
示例5: test_get_project_by_team_should_be_a_equal_to_project_dict
# 需要导入模块: from tests.factories import TeamFactory [as 别名]
# 或者: from tests.factories.TeamFactory import add_projects [as 别名]
def test_get_project_by_team_should_be_a_equal_to_project_dict(self):
TeamFactory.add_projects(self.team, 2)
project = self.team.projects[1]
response = self.fetch_with_headers("/teams/%s/projects/%s" % (self.team.name, project.name))
expect(response.code).to_equal(200)
obj = response.body
if isinstance(obj, six.binary_type):
obj = obj.decode('utf-8')
expect(loads(obj)).to_be_like(project.to_dict())
示例6: test_get_last_3_load_tests_for_all_projects_when_owner
# 需要导入模块: from tests.factories import TeamFactory [as 别名]
# 或者: from tests.factories.TeamFactory import add_projects [as 别名]
def test_get_last_3_load_tests_for_all_projects_when_owner(self):
LoadTestFactory.add_to_project(4, user=self.user, team=self.team, project=self.project)
LoadTestFactory.add_to_project(4, user=self.user, team=self.team, project=self.team.projects[1])
team = TeamFactory.create(owner=self.user)
TeamFactory.add_projects(team, 1)
LoadTestFactory.add_to_project(4, user=self.user, team=team, project=team.projects[0])
LoadTestFactory.add_to_project(4, user=UserFactory.create())
loaded_tests = list(LoadTest.get_by_user(self.user))
expect(loaded_tests).to_length(9)
示例7: setUp
# 需要导入模块: from tests.factories import TeamFactory [as 别名]
# 或者: from tests.factories.TeamFactory import add_projects [as 别名]
def setUp(self):
super(ShowTestResultForTeamProjectAndTestTest, self).setUp()
self.user = UserFactory.create(with_token=True)
self.team = TeamFactory.create(owner=self.user)
TeamFactory.add_projects(self.team, 2)
self.project = self.team.projects[0]
self.load_test = LoadTestFactory.create(created_by=self.user, team=self.team, project_name=self.project.name, status="Finished")
self.load_test.save()
self.config = TestConfigurationFactory.build()
self.config2 = TestConfigurationFactory.build()
示例8: test_list_load_tests_by_team_and_project
# 需要导入模块: from tests.factories import TeamFactory [as 别名]
# 或者: from tests.factories.TeamFactory import add_projects [as 别名]
def test_list_load_tests_by_team_and_project(self):
team = TeamFactory.create(owner=self.user)
TeamFactory.add_projects(team, 1)
project = team.projects[0]
LoadTestFactory.add_to_project(25, user=self.user, team=team, project=project)
load_tests = LoadTest.get_sliced_by_team_and_project_name(team, project.name, 20)
uuids = _get_print_lines_for_load_tests(load_tests)
result = self.execute("list", team=team.name, project=project.name)
expect(result).to_be_like(BASE_LOAD_TESTS_TABLE_PRINT % (team.name, project.name, "".join(uuids)))
示例9: test_can_git_clone_in_specific_branch
# 需要导入模块: from tests.factories import TeamFactory [as 别名]
# 或者: from tests.factories.TeamFactory import add_projects [as 别名]
def test_can_git_clone_in_specific_branch(
self, run_config_mock, load_config_mock, validate_mock, save_mock, clone_mock
):
team = TeamFactory.create()
TeamFactory.add_projects(team, 1)
user = team.owner
project = team.projects[0]
load_test = LoadTestFactory.add_to_project(1, user=user, team=team, project=project, branch="test")
runner = BenchRunner()
runner.run_project_tests("some-path-doesnt-matter", str(load_test.uuid), duration=1)
expect(clone_mock.call_args_list[0][1]["branch"]).to_be_like("test")
示例10: test_get_project_by_team_should_be_a_json
# 需要导入模块: from tests.factories import TeamFactory [as 别名]
# 或者: from tests.factories.TeamFactory import add_projects [as 别名]
def test_get_project_by_team_should_be_a_json(self):
TeamFactory.add_projects(self.team, 2)
project = self.team.projects[1]
response = self.fetch_with_headers("/teams/%s/projects/%s" % (self.team.name, project.name))
expect(response.code).to_equal(200)
obj = response.body
if isinstance(obj, six.binary_type):
obj = obj.decode('utf-8')
try:
loads(obj)
assert True
except ValueError:
raise AssertionError("Should be possible to load a json from response")
示例11: test_can_schedule_in_specific_branch
# 需要导入模块: from tests.factories import TeamFactory [as 别名]
# 或者: from tests.factories.TeamFactory import add_projects [as 别名]
def test_can_schedule_in_specific_branch(self):
team = TeamFactory.create(owner=self.user)
TeamFactory.add_projects(team, 2)
project_name = team.projects[0].name
result = self.execute("schedule", team=team.name, project=project_name, url="http://www.globo.com", branch="test-branch")
expect(result).to_be_like(
"Scheduled a new load test for project '%s' (branch '%s') in team '%s' at '%s' target." % (
project_name, "test-branch", team.name, self.target
)
)
load_test = LoadTest.objects.filter(team=team, project_name=project_name).first()
expect(load_test).not_to_be_null()
expect(load_test.git_branch).to_equal("test-branch")
示例12: main
# 需要导入模块: from tests.factories import TeamFactory [as 别名]
# 或者: from tests.factories.TeamFactory import add_projects [as 别名]
def main(args=None):
if args is None:
args = sys.argv[1:]
parser = argparse.ArgumentParser()
parser.add_argument('--conf', '-c', default=DEFAULT_CONFIG_PATH, help="Path to configuration file.")
options = parser.parse_args(args)
config = Config.load(path=options.conf, conf_name=split(options.conf)[-1], lookup_paths=[
os.curdir,
expanduser('~'),
'/etc/',
])
connect(
config.MONGO_DB,
host=config.MONGO_HOST,
port=config.MONGO_PORT,
username=config.MONGO_USER,
password=config.MONGO_PASS
)
user = UserFactory.create()
team = TeamFactory.create(owner=user)
TeamFactory.add_projects(team, 1)
project = team.projects[0]
config = TestConfigurationFactory.build()
load_test1 = LoadTestFactory.add_to_project(1, user=user, team=team, project=project)
load_test1.results.append(TestResultFactory.build(config=config))
load_test1.save()
print "load test 1: %s" % load_test1.uuid
print "test result for load test 1: %s" % load_test1.results[0].uuid
load_test2 = LoadTestFactory.add_to_project(1, user=user, team=team, project=project)
load_test2.results.append(TestResultFactory.build(config=config))
load_test2.results.append(TestResultFactory.build())
load_test2.save()
load_test3 = LoadTestFactory.add_to_project(1, user=user, team=team, project=project)
load_test3.results.append(TestResultFactory.build(config=config))
load_test3.save()
load_test4 = LoadTestFactory.add_to_project(1, user=user, team=team, project=project)
load_test4.results.append(TestResultFactory.build(config=config))
load_test4.save()
print "load test 2: %s" % load_test2.uuid
print "test result 1 for load test 2: %s" % load_test2.results[0].uuid
print "test result 2 for load test 2: %s" % load_test2.results[1].uuid
print "url for trend: %s/%s/%s/%s/%s/" % (team.name, project.name, config.module, config.class_name, config.test_name)
示例13: test_to_dict
# 需要导入模块: from tests.factories import TeamFactory [as 别名]
# 或者: from tests.factories.TeamFactory import add_projects [as 别名]
def test_to_dict(self):
team = TeamFactory.create()
TeamFactory.add_members(team, 2)
TeamFactory.add_projects(team, 2)
expect(team.to_dict()).to_be_like({
"name": team.name,
"owner": team.owner.email,
"members": [
team.members[0].email,
team.members[1].email,
],
"projects": [
team.projects[0].to_dict(),
team.projects[1].to_dict(),
]
})
示例14: test_can_schedule_with_default_project
# 需要导入模块: from tests.factories import TeamFactory [as 别名]
# 或者: from tests.factories.TeamFactory import add_projects [as 别名]
def test_can_schedule_with_default_project(self):
team = TeamFactory.create(owner=self.user)
TeamFactory.add_projects(team, 2)
project_name = team.projects[0].name
self.execute("default-set", project=project_name)
result = self.execute("schedule", team=team.name, url="http://www.globo.com")
expect(result).to_be_like(
"Scheduled a new load test for project '%s' in team '%s' at '%s' target." % (
project_name, team.name, self.target
)
)
load_test = LoadTest.objects.filter(team=team, project_name=project_name).first()
expect(load_test).not_to_be_null()
expect(load_test.team.id).to_equal(team.id)
expect(load_test.project_name).to_equal(project_name)
expect(load_test.created_by.id).to_equal(self.user.id)
示例15: test_list_load_tests_by_user_only
# 需要导入模块: from tests.factories import TeamFactory [as 别名]
# 或者: from tests.factories.TeamFactory import add_projects [as 别名]
def test_list_load_tests_by_user_only(self):
team1 = TeamFactory.create(owner=self.user)
team2 = TeamFactory.create(owner=self.user)
TeamFactory.add_projects(team1, 2)
TeamFactory.add_projects(team2, 3)
project1 = team1.projects[0]
project2 = team1.projects[1]
project3 = team2.projects[0]
project4 = team2.projects[1]
project5 = team2.projects[2]
LoadTestFactory.add_to_project(4, user=self.user, team=team1, project=project1)
LoadTestFactory.add_to_project(4, user=self.user, team=team1, project=project2)
LoadTestFactory.add_to_project(4, user=self.user, team=team2, project=project3)
LoadTestFactory.add_to_project(4, user=self.user, team=team2, project=project4)
LoadTestFactory.add_to_project(4, user=self.user, team=team2, project=project5)
load_tests1 = LoadTest.get_sliced_by_team_and_project_name(team1, project1.name, 3)
load_tests2 = LoadTest.get_sliced_by_team_and_project_name(team1, project2.name, 3)
load_tests3 = LoadTest.get_sliced_by_team_and_project_name(team2, project3.name, 3)
load_tests4 = LoadTest.get_sliced_by_team_and_project_name(team2, project4.name, 3)
load_tests5 = LoadTest.get_sliced_by_team_and_project_name(team2, project5.name, 3)
uuids1 = _get_print_lines_for_load_tests(load_tests1)
uuids2 = _get_print_lines_for_load_tests(load_tests2)
uuids3 = _get_print_lines_for_load_tests(load_tests3)
uuids4 = _get_print_lines_for_load_tests(load_tests4)
uuids5 = _get_print_lines_for_load_tests(load_tests5)
result = self.execute("list")
expect(result).to_be_like((BASE_LOAD_TESTS_TABLE_PRINT * 5) % (
team1.name, project1.name, "".join(uuids1),
team1.name, project2.name, "".join(uuids2),
team2.name, project3.name, "".join(uuids3),
team2.name, project4.name, "".join(uuids4),
team2.name, project5.name, "".join(uuids5)
))