How to use create_template method in localstack

Best Python code snippet using localstack_python

test_operators.py

Source:test_operators.py Github

copy

Full Screen

...11class ResourceSelectionShould(CampTest):12 def setUp(self):13 self.scenario = Scenario()14 def test_handle_files(self):15 self.scenario.create_template("server", "Dockerfile")16 self.scenario.create_template("server", "nginx_settings.py")17 self.scenario.create_template("server", "apache_settings.py")18 self.scenario.create_model(19 "goals:\n"20 " running: [ MyService ]\n"21 "components:\n"22 " server:\n"23 " provides_services: [ MyService ]\n"24 " variables:\n"25 " proxy:\n"26 " values: [ nginx, apache ]\n"27 " realization:\n"28 " - select: \n"29 " - server/nginx_settings.py\n"30 " - server/apache_settings.py\n"31 " as: server/settings.py\n"32 " implementation:\n"33 " docker:\n"34 " file: server/Dockerfile\n"35 )36 self.generate_all()37 self.realize()38 for each_configuration in self.scenario.generated_configurations:39 self._assert_generated(each_configuration, "images/server_0/settings.py")40 def test_handle_selecting_without_renaming(self):41 self.scenario.create_template("server", "Dockerfile")42 self.scenario.create_template("server", "nginx_settings.py")43 self.scenario.create_template("server", "apache_settings.py")44 self.scenario.create_model(45 "goals:\n"46 " running: [ MyService ]\n"47 "components:\n"48 " server:\n"49 " provides_services: [ MyService ]\n"50 " variables:\n"51 " proxy:\n"52 " values: [ nginx, apache ]\n"53 " realization:\n"54 " - select: \n"55 " - server/nginx_settings.py\n"56 " - server/apache_settings.py\n"57 " implementation:\n"58 " docker:\n"59 " file: server/Dockerfile\n"60 )61 self.generate_all()62 self.realize()63 for each_configuration in self.scenario.generated_configurations:64 if each_configuration.model.resolve("server_0")["proxy"] == "nginx":65 self._assert_generated(each_configuration,66 "images/server_0/nginx_settings.py")67 elif each_configuration.model.resolve("server_0")["proxy"] == "apache":68 self._assert_generated(each_configuration,69 "images/server_0/apache_settings.py")70 def test_handle_directory(self):71 self.scenario.create_template("server", "Dockerfile")72 self.scenario.create_template("server", "nginx/settings.py")73 self.scenario.create_template("server", "apache/settings.py")74 self.scenario.create_model(75 "goals:\n"76 " running: [ MyService ]\n"77 "components:\n"78 " server:\n"79 " provides_services: [ MyService ]\n"80 " variables:\n"81 " proxy:\n"82 " values: [ nginx, apache ]\n"83 " realization:\n"84 " - select: \n"85 " - server/nginx\n"86 " - server/apache\n"87 " as: server/config\n"88 " implementation:\n"89 " docker:\n"90 " file: server/Dockerfile\n"91 )92 self.generate_all()93 self.realize()94 for each_configuration in self.scenario.generated_configurations:95 self._assert_generated(each_configuration, "images/server_0/config")96class ComponentResourceSelectionShould(CampTest):97 def setUp(self):98 self.scenario = Scenario()99 def test_handle_files(self):100 self.scenario.create_template("nginx", "Dockerfile")101 self.scenario.create_template(None, "nginx_docker-compose.yml")102 self.scenario.create_template(None, "apache_docker-compose.yml")103 self.scenario.create_model(104 "goals:\n"105 " running: [ MyService ]\n"106 "components:\n"107 " nginx:\n"108 " provides_services: [ MyService ]\n"109 " realization:\n"110 " - select: nginx_docker-compose.yml\n"111 " instead_of:\n"112 " - apache_docker-compose.yml\n"113 " as: docker-compose.yml\n"114 " implementation:\n"115 " docker:\n"116 " file: nginx/Dockerfile\n"117 )118 self.generate_all()119 self.realize()120 for each_configuration in self.scenario.generated_configurations:121 self._assert_generated(each_configuration, "docker-compose.yml")122 for each_configuration in self.scenario.generated_configurations:123 self._assert_missing(each_configuration,124 "nginx_docker-compose.yml",125 "apache_docker-compose.yml")126 # See Issue 98127 def test_handle_files_of_another_instance(self):128 self.scenario.create_template("app", "Dockerfile", "FROM camp/runtime")129 self.scenario.create_template("app", "tomcat_entrypoint.sh")130 self.scenario.create_template("app", "jetty_entrypoint.sh")131 self.scenario.create_template("jetty", "Dockerfile")132 self.scenario.create_model(133 "goals:\n"134 " running: [ MyService ]\n"135 "components:\n"136 " app:\n"137 " provides_services: [ MyService ]\n"138 " requires_features: [ Servlet ]\n"139 " implementation:\n"140 " docker:\n"141 " file: app/Dockerfile\n"142 " jetty:\n"143 " provides_features: [ Servlet ]\n"144 " realization:\n"145 " - select: app/jetty_entrypoint.sh\n"146 " instead_of:\n"147 " - app/tomcat_entrypoint.sh\n"148 " as: app/entrypoint.sh\n"149 " implementation:\n"150 " docker:\n"151 " file: jetty/Dockerfile\n"152 )153 self.generate_all()154 self.realize()155 for each_configuration in self.scenario.generated_configurations:156 self._assert_generated(each_configuration,157 "images/app_0/entrypoint.sh")158 for each_configuration in self.scenario.generated_configurations:159 self._assert_missing(each_configuration,160 "images/app_0/tomcat_entrypoint.sh",161 "images/app_0/jetty_entrypoint.sh")162 def test_select_resource_before_substitutions_take_place(self):163 self.scenario.create_template("nginx", "Dockerfile")164 self.scenario.create_template(None,165 "nginx_docker-compose.yml",166 "build: ./nginx\n"167 "nginx_variable=value")168 self.scenario.create_template(None,169 "apache_docker-compose.yml",170 "apache_variable=value")171 self.scenario.create_model(172 "goals:\n"173 " running: [ MyService ]\n"174 "components:\n"175 " nginx:\n"176 " provides_services: [ MyService ]\n"177 " variables:\n"178 " version:\n"179 " values: [ v2.0 ]\n"180 " realization:\n"181 " - targets: [docker-compose.yml]\n"182 " pattern: nginx_variable=value\n"...

Full Screen

Full Screen

test_template.py

Source:test_template.py Github

copy

Full Screen

1invalid_token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmcmVzaCI6ZmFsc2UsImlhdCI6MTY1NDUwMzk3NSwianRpIjoiMGE1OWEzZDUtY2U0Ny00NTM1LThiZWQtYTdhMzU5MDg1NjljIiwidHlwZSI6ImFjY2VzcyIsInN1YiI6eyJfaWQiOiI2Mjk3YTcxYjcxZGMxMGNlMDJiZjVmYjUiLCJmaXJzdF9uYW1lIjoiQXlvIiwibGFzdF9uYW1lIjoiT2xheWl3b2xhIiwiZW1haWwiOiJheW9vbGF5aXdvbGFAZ21haWwuY29tIn0sIm5iZiI6MTY1NDUwMzk3NSwiZXhwIjoxNjU0NTA0ODc1fQ.JxWeKXAL7zodCsXxSB0TwfjW_e2mB9Qa4nHfKF1_V2Y"2def test_create_template(client, token):3 resp = client.post(4 "/template",5 json={6 "template_name": "Template",7 "subject": "Evolution",8 "body": "Some template evolution here haha",9 },10 headers={"Authorization": f"Bearer {token}"},11 )12 assert resp.status_code == 20113 assert "data" in resp.json14def test_create_template_invalid_payload(client, token):15 resp = client.post(16 "/template",...

Full Screen

Full Screen

template_controller_test.py

Source:template_controller_test.py Github

copy

Full Screen

...19 #20 # Tests21 #22 def test_create_succeeds(self):23 template_controller.create_template('test template',24 'test_template.tex', '~/.texviper/templates', '')25 def test_create_fails_with_existing_template(self):26 template_controller.create_template('test template',27 'test_template.tex', '~/.texviper/templates', '')28 self.assertRaises(FileExistsError,29 template_controller.create_template, 'test template',30 'test_template.tex', '~/.texviper/templates', ''31 )32 def test_create_fails_with_invalid_values(self):33 self.assertRaises(InvalidValueError,34 template_controller.create_template, '', 'test_template.tex', '~/.texviper/templates', '')35 self.assertRaises(InvalidValueError,36 template_controller.create_template, 'test template', '', '~/.texviper/templates', '')37 self.assertRaises(InvalidValueError,38 template_controller.create_template, 'test template', 'test_template.tex', '', '')39 def test_source_is_written_to_file(self):40 source = '''\\documentclass{article}41\\begin{document}42\\end{document}'''43 template_controller.create_template('test template',44 'test_template.tex', '~/.texviper/templates', source)45 self.assertEqual(46 Path('~/.texviper/templates/test_template.tex').expanduser().read_text(),47 source48 )49 def test_get_templates_returns_all_templates(self):50 template_controller.create_template('template 1',51 'template_1.tex', '~/.texviper/templates', '')52 template_controller.create_template('template 2',53 'template_2.tex', '~/.texviper/templates', '')54 template_controller.create_template('template 3',55 'template_3.tex', '~/.texviper/templates', '')56 self.assertEqual(len(template_controller.get_templates()), 3)57 def test_get_source_works_correctly(self):58 source = '''\\documentclass{article}59\\begin{document}60\\end{document}'''61 template = template_controller.create_template('test template',62 'test_template.tex', '~/.texviper/templates', source)63 self.assertEqual(template_controller.get_source(64 template.template_id), source)65 def remove_template_removes_template(self):66 template = template_controller.create_template('test template',67 'test_template.tex', '~/.texviper/templates', '')68 template_controller.remove_template(template.template_id)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful