Untitled
unknown
plain_text
5 years ago
794 B
11
Indexable
def create_course(self):
test_img = 'test_img.jpg'
with open(test_img, 'rb') as img_file:
now = datetime.datetime.now
DATETIME_FORMAT = 'd.m.Y H:i'
tomorrow = now() + timedelta(days=1)
week_ago = now() + timedelta(days=7)
data = {'name': 'testcase', 'started_at': tomorrow,
'ended_at': week_ago, 'description': 'Desc', 'category': 1}
files = {'image': img_file}
url = '{}/api/v1/my_courses/'.format(self.root)
headers = self.get_headers(self.phone)
print(headers)
print(data)
response = requests.post(url=url, data=data, files=files, headers=headers)
print(response.status_code)
print(response.json())Editor is loading...