def test_add_1(): """tasks.get() использует id, возвращаемый из add().""" task = Task('breathe', 'BRIAN', True) task_id = tasks.add(task) t_from_db = tasks.get(task_id) # все, кроме идентификатора, должно быть одинаковым assert equivalent(t_from_db, task)
def test_add_b(tasks_db, b_task): """ Using a list of ids. """ task_id = tasks.add(b_task) t_from_db = tasks.get(task_id) assert equivalent(t_from_db, b_task)
def test_add_c(tasks_db, c_task): """ Use fixture with generated ids. """ task_id = tasks.add(c_task) t_from_db = tasks.get(task_id) assert equivalent(t_from_db, c_task)
def test_add_4(task): """ Slightly different take. """ task_id = tasks.add(task) t_from_db = tasks.get(task_id) assert equivalent(t_from_db, task)
def test_add_a(tasks_db, a_task): """ Using a_task fixture (no ids). """ task_id = tasks.add(a_task) t_from_db = tasks.get(task_id) assert equivalent(t_from_db, a_task)
def test_added_task_has_id_set(): """Make sure the task_id field is set by tasks.add().""" new_task = Task('sit in chair', owner='me', done=True) task_id = tasks.add(new_task) task_from_db = tasks.get(task_id) assert task_from_db.id == task_id
def test_add_1(): """tasks.get() using id returned from add() works.""" task = Task('breathe', 'BRIAN', True) task_id = tasks.add(task) t_from_db = tasks.get(task_id) # everthing bug the id should be the same assert equivalent(t_from_db, task)
def test_valid_id(self, task): """ We can use the same data for multiple tests. """ task_id = tasks.add(task) t_from_db = tasks.get(task_id) assert t_from_db.id == task_id
def test_add_2(task): """ Demonstrate parametrize with one parameter. """ task_id = tasks.add(task) t_from_db = tasks.get(task_id) assert equivalent(t_from_db, task)
def test_add_1(): '''tasks.get() using id returned from add() works.''' task = Task('breathe', 'brian', True) task_id = tasks.add(task) t_from_db = tasks.get(task_id) # everything but id should be the same assert equivalent(t_from_db, task)
def test_equivalent(self, task): """ Similar test, just within a class. """ task_id = tasks.add(task) t_from_db = tasks.get(task_id) assert equivalent(t_from_db, task)
def test_add_2(task): # テストのパラメータ化→@pytest.mark.parametrizeを使う # 関数の引数とparametrizeの第一引数は同じにする task_id = tasks.add(task) t_from_db = tasks.get(task_id) assert equivalent(t_from_db, task)
def registry_get(self, api): url = "https://%s/v2/%s" % (self.registry, api) response = get(url, auth=(self.user, self.password)) if response.status_code == 401: challenge = response.headers['Www-Authenticate'] if challenge.startswith("Bearer "): challenge = challenge[7:] opts = urllib2.parse_keqv_list(urllib2.parse_http_list(challenge)) authresp = get("{realm}?service={service}&scope={scope}".format(**opts), auth=(self.user, self.password)) if authresp.ok: token = authresp.json()['token'] response = get(url, headers={'Authorization': 'Bearer %s' % token}) else: raise TaskError("problem authenticating with docker registry: [%s] %s" % (authresp.status_code, authresp.content)) return response
def test_add_5(task): """Demonstrate ids. You see data in console. """ task_id = tasks.add(task) t_from_db = tasks.get(task_id) assert equivalent(t_from_db, task)
def test_added_task_has_id_set(): new_task = Task('sit in chair', owner='me', done=True) task_id = tasks.add(new_task) task_from_db = tasks.get(task_id) assert task_from_db.id == task_id
def test_add_1(): """tasks.get() using id returend from add() works.""" task = Task('breathe', 'BRIAN', True) task_id = tasks.add(task) t_from_db = tasks.get(task_id) # ID意外は同じはず assert equivalent(t_from_db, task)
def test_add_3(summary, owner, done): """ Demonstrate parametrize with multiple parameters. """ task = Task(summary, owner, done) task_id = tasks.add(task) t_from_db = tasks.get(task_id) assert equivalent(t_from_db, task)
def test_added_task_has_id_set(tasks_db): new_task = Task("sit in chair", owner='me', done=True) task_id = tasks.add(new_task) task_from_db = tasks.get(task_id) assert task_from_db.id == task_id assert task_from_db[:-1] == new_task[:-1]
def test_add_3(summary, owner, done): # テストパラメータが複数の場合のパラメータ化 # タスクの中身をタプルで渡す task = Task(summary, owner, done) task_id = tasks.add(task) t_from_db = tasks.get(task_id) assert equivalent(t_from_db, task)
def test_add_1(): """ tasks.get() using id returned from add() works. """ task = Task("breathe", "BRIAN", True) task_id = tasks.add(task) t_from_db = tasks.get(task_id) # ID以外は同じはす assert equivalent(t_from_db, task)
def test_add_1(): """tasks.get() using id returned from add() works.""" task = Task('breathe', 'BRIAN', True) task_id = tasks.add(task) # gives us the id of the task t_from_db = tasks.get( task_id ) # with the id of the task gives all parameters (summary,owner,done) # everything but the id should be the same assert equivalent(t_from_db, task)
def test_get(self): kwargs = { 'token': '050814a54ac5c81b990140c3c43278031d391676', } text = get(self.client, self.repository, jars_uri, **kwargs) self.assertIsInstance(text, Text) text.content.delete()
def test_added_task_has_id_set(): """Make sure the task_id field is set by tasks.add().""" # GIVEN an initialized tasks db # AND a new task is added new_task = Task('sit in chair', owner='me', done=True) task_id = tasks.add(new_task) # WHEN task is retrieved task_from_db = tasks.get(task_id) # THEN task_id matches id field assert task_from_db.id == task_id
def tasks_api(): if request.method == "GET": return tasks.get() elif request.method == "POST": return tasks.post() elif request.method == "PATCH": return tasks.update() elif request.method == "DELETE": return tasks.delete()
def test_Add_1(): """tasks.get() using id returned from add() works.""" task = Task("breathe", "BRIAN", True) task_id = tasks.add(task) # データベースにtaskを追加 print(task_id) t_from_db = tasks.get( task_id) # task_idをdbから取得使ってるのはTinyDB。細かいところは追々コード読めばいい。 print(t_from_db) # ID以外は同じはず assert equivalent(t_from_db, task)
def test_added_task_has_id_set(): """Make sure the task_id field is set by tasks.add().""" # GIVEN tasks_dbが初期化済みで # AND 新しいタスクが追加されるとすれば new_task = Task('sit on a chair', owner='John', done=True) task_id = tasks.add(new_task) # WHEN タスクが取得された時に task_from_db = tasks.get(task_id) # THEN task_idはidフィールドと一致する assert task_from_db.id == task_id
def test_added_task_has_id_set(tasks_db): """Убедимся, что поле task_id установлено tasks.add().""" # ДАЕТ инициализированные задачи db # И добавлена новая задача new_task = Task('sit in chair', owner='me', done=True) task_id = tasks.add(new_task) # КОГДА задача получена task_from_db = tasks.get(task_id) # ТОГДА task_id соответствует полю id assert task_from_db.id == task_id
def test_added_task_has_id_set(): """Убедимся, что поле task_id установлено tasks.add().""" # GIVEN an initialized tasks db # AND a new task is added new_task = Task('sit in chair', owner='me', done=True) task_id = tasks.add(new_task) # WHEN task is retrieved task_from_db = tasks.get(task_id) # THEN task_id matches id field assert task_from_db.id == task_id
def test_add_taks_has_id_set(): """Make sure the task_id field is set by tasks.add().""" # given an intialized tasks db # Add a new task is added new_task = Task('sit in chair', owner='me', done=True) task_id = tasks.add(new_task) # when task is retrived task_from_db = tasks.get(task_id) # then task_id matches id field assert task_from_db.id == task_id
def test_add_task_has_id_set(): """make sure task_is filed is set""" # GIVEN initialize db # auto run initialized_tasks_db # And new task id new_task = Task('sit in chair', owner='me', done=True) task_id = tasks.add(new_task) # WHEN task retrieve task_from_db = tasks.get(task_id) # THEN task_id match assert task_from_db.id == task_id
def test_added_task_has_id_set(tasks_db): """Make sure the task_id field is set by tasks.add().""" # GIVEN an initialized tasks db # AND a new task is added new_task = Task('sit in chair', owner='me', done=True) task_id = tasks.add(new_task) # WHEN task is retrieved task_from_db = tasks.get(task_id) # THEN task_id matches id field assert task_from_db.id == task_id # AND contents are equivalent (except for id) # the [:-1] syntax returns a list with all but the last element assert task_from_db[:-1] == new_task[:-1]
def get(response, params): if len(params) >= 5: item = params[3] id = params[4] if item == "board": if len(params) == 6 and params[5] == "categories": response = boards.getCategories(response, id) elif len(params) == 5: response = boards.get(response, id) else: response.setInvalid() elif item == "category": if len(params) == 6 and params[5] == "tasks": response = categories.getTasks(response, id) elif len(params) == 5: response = categories.get(response, id) else: response.setInvalid() elif item == "task": if len(params) == 6 and params[5] == "users": response = tasks.getUsers(response, id) elif len(params) == 5: response = tasks.get(response, id) else: response.setInvalid() elif item == "user": if len(params) == 6 and params[5] == "tasks": response = users.getTasks(response, id) elif len(params) == 5: response = users.get(response, id) else: response.setInvalid() else: response.setInvalid() else: response.setMoreInfo() return response
#!/usr/bin/env python from tasks import get from connection import hub import models hub.connect() loc = 'http://jp.python-requests.org/en/latest/' with hub.transaction(): models.URLs.parse(loc) get(loc)
def execute(self): obj = self.properties()['object'].get_value_for_datastore(self) import tasks return tasks.get(self.task)(self, obj)
def test_get(self): text = get(self.client, self.repository, wikiURL) self.assertIsInstance(text, Text) text.content.delete()