Exemple #1
0
    def test_todos_post(self):
        file_name = "test_data_todos.json"
        test_data = {
            "title": "Test",
            "user_id": "123",
            "description": "test",
            "date_due": "2019-08-22T23:51:28.873Z",
        }
        url = f"/api/v1/todo/create/?delay=1"

        response = client.post(url, json=test_data)

        state = response.status_code
        data = response.json()
        save_json(file_name, data)
        assert state == 200
Exemple #2
0
    def test_save_json(self):

        file_named = "test_1.json"
        json_data = []
        for _ in range(10):
            sample_dict = {"name": "bob", "date": str(time_str)}
            json_data.append(sample_dict)

        result = save_json(file_named, json_data)
        assert result == "complete"
Exemple #3
0
    def test_save_json_slash_exception(self):

        file_named = "tes/t_1.json"
        json_data = []
        for _ in range(10):
            sample_dict = {"name": "bob", "date": str(time_str)}
            json_data.append(sample_dict)

        with pytest.raises(Exception):
            assert save_json(file_named, json_data)
Exemple #4
0
            char_list.append(char)

    err_list = []
    count = 0

    for l in tqdm(char_list, desc="left char", leave=False, ascii=True):
        for r in tqdm(char_list, desc="right char", leave=False, ascii=True):

            text = f"{l}found one{r} {l}found two{r}"
            data = pattern_between_two_char(text, l, r)

            if "Error" in data:
                err_list.append(data)

    return err_list, char_list, count


if __name__ == "__main__":
    t0 = time.time()
    err_list, char_list, count = run_ascii_two()
    t1 = time.time() - t0
    combinations = len(char_list) * len(char_list)
    print(
        f"process took {t1:.2f} seconds with {combinations:,} combinations and a count cycle of {count:,}"
    )

    if len(err_list) != 0:
        save_json("err.json", err_list)
    else:
        print("there were no errors")
Exemple #5
0
    def test_save_json_exception(self):
        sample_str = "not a dict"
        file_named = "test_1_error.json"

        with pytest.raises(Exception):
            assert save_json(file_named, sample_str)