def test_request_dyn_variable(self): profile = self.make_profile() self.add_request(profile, dyn_variable='foo') xml = models.generate_config_xml(profile) self.assertXML(xml, [ '<!DOCTYPE tsung SYSTEM "/usr/share/tsung/tsung-1.0.dtd">', '<tsung loglevel="notice" version="1.0">', ' <clients/>', ' <servers>', ' <server host="example.com" port="80" type="tcp"/>', ' </servers>', ' <load>', ' <arrivalphase duration="1" phase="1" unit="minute">', ' <users interarrival="0.00" unit="second"/>', ' </arrivalphase>', ' </load>', ' <options>', ' <option name="user_agent" type="ts_http"/>', ' </options>', ' <sessions>', ' <session name="testgc" probability="100" type="ts_http">', ' <thinktime random="true" value="1"/>', ' <request>', ' <dyn_variable name="foo"/>', ' <http method="" url="http://example.com" version="1.1"/>', ' </request>', ' </session>', ' </sessions>', '</tsung>', ])
def test_request_put(self): profile = self.make_profile() self.add_request( profile, path='/foo', method='PUT', content_type='application/json', content='{}') xml = models.generate_config_xml(profile) self.assertXML(xml, [ '<!DOCTYPE tsung SYSTEM "/usr/share/tsung/tsung-1.0.dtd">', '<tsung loglevel="notice" version="1.0">', ' <clients/>', ' <servers>', ' <server host="example.com" port="80" type="tcp"/>', ' </servers>', ' <load>', ' <arrivalphase duration="1" phase="1" unit="minute">', ' <users interarrival="0.00" unit="second"/>', ' </arrivalphase>', ' </load>', ' <options>', ' <option name="user_agent" type="ts_http"/>', ' </options>', ' <sessions>', ' <session name="testgc" probability="100" type="ts_http">', ' <thinktime random="true" value="1"/>', ' <request>', (' <http method="PUT" url="http://example.com/foo"' ' version="1.1" content_type="application/json" contents="{}"/>'), ' </request>', ' </session>', ' </sessions>', '</tsung>', ])
def test_request_dyn_variable(self): profile = self.make_profile() self.add_request(profile, dyn_variable='foo') xml = models.generate_config_xml(profile) self.assertXML(xml, [ '<!DOCTYPE tsung SYSTEM "/usr/share/tsung/tsung-1.0.dtd">', '<tsung loglevel="notice" version="1.0">', ' <clients/>', ' <servers>', ' <server host="example.com" port="80" type="tcp"/>', ' </servers>', ' <load>', ' <arrivalphase duration="1" phase="1" unit="minute">', ' <users interarrival="0.00" unit="second"/>', ' </arrivalphase>', ' </load>', ' <options>', ' <option name="user_agent" type="ts_http"/>', ' </options>', ' <sessions>', ' <session name="testgc" probability="100" type="ts_http">', ' <thinktime random="true" value="1"/>', ' <request>', ' <dyn_variable name="foo"/>', ' <http method="" url="http://example.com" version="1.1"/>', ' </request>', ' </session>', ' </sessions>', '</tsung>', ])
def test_request_put(self): profile = self.make_profile() self.add_request(profile, path='/foo', method='PUT', content_type='application/json', content='{}') xml = models.generate_config_xml(profile) self.assertXML(xml, [ '<!DOCTYPE tsung SYSTEM "/usr/share/tsung/tsung-1.0.dtd">', '<tsung loglevel="notice" version="1.0">', ' <clients/>', ' <servers>', ' <server host="example.com" port="80" type="tcp"/>', ' </servers>', ' <load>', ' <arrivalphase duration="1" phase="1" unit="minute">', ' <users interarrival="0.00" unit="second"/>', ' </arrivalphase>', ' </load>', ' <options>', ' <option name="user_agent" type="ts_http"/>', ' </options>', ' <sessions>', ' <session name="testgc" probability="100" type="ts_http">', ' <thinktime random="true" value="1"/>', ' <request>', (' <http method="PUT" url="http://example.com/foo"' ' version="1.1" content_type="application/json" contents="{}"/>'), ' </request>', ' </session>', ' </sessions>', '</tsung>', ])
def profile_run(request, id): profile = Profile.objects.get(id=id) test = Test.objects.create(profile=profile, running=False) task = tasks.run_test.delay(test, generate_config_xml(profile)) test.task_id = task.task_id test.save() return redirect('profile_view', id=id)
def profile_run(request, id): profile = Profile.objects.get(id=id) test = Test.objects.create( profile=profile, running=False ) task = tasks.run_test.delay(test, generate_config_xml(profile)) test.task_id = task.task_id test.save() return redirect('profile_view', id=id)
def test_empty_profile(self): profile = self.make_profile() xml = models.generate_config_xml(profile) self.assertXML(xml, [ '<!DOCTYPE tsung SYSTEM "/usr/share/tsung/tsung-1.0.dtd">', '<tsung loglevel="notice" version="1.0">', ' <clients/>', ' <servers>', ' <server host="example.com" port="80" type="tcp"/>', ' </servers>', ' <load>', ' <arrivalphase duration="1" phase="1" unit="minute">', ' <users interarrival="0.00" unit="second"/>', ' </arrivalphase>', ' </load>', ' <options>', ' <option name="user_agent" type="ts_http"/>', ' </options>', ' <sessions>', ' <session name="testgc" probability="100" type="ts_http"/>', ' </sessions>', '</tsung>', ])
def test_empty_profile(self): profile = self.make_profile() xml = models.generate_config_xml(profile) self.assertXML(xml, [ '<!DOCTYPE tsung SYSTEM "/usr/share/tsung/tsung-1.0.dtd">', '<tsung loglevel="notice" version="1.0">', ' <clients/>', ' <servers>', ' <server host="example.com" port="80" type="tcp"/>', ' </servers>', ' <load>', ' <arrivalphase duration="1" phase="1" unit="minute">', ' <users interarrival="0.00" unit="second"/>', ' </arrivalphase>', ' </load>', ' <options>', ' <option name="user_agent" type="ts_http"/>', ' </options>', ' <sessions>', ' <session name="testgc" probability="100" type="ts_http"/>', ' </sessions>', '</tsung>', ])