diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..1f245a8f --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_style = space +indent_size = 4 +insert_final_newline = true +trim_trailing_whitespace = true + +[*.{sh,yaml,yml}] +indent_size = 2 diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..722ebf9e --- /dev/null +++ b/.gitignore @@ -0,0 +1,125 @@ + +# Created by https://www.gitignore.io/api/python +# Edit at https://www.gitignore.io/?templates=python + +### Python ### +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +### Python Patch ### +.venv/ + +# End of https://www.gitignore.io/api/python diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..d4c60028 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,17 @@ +repos: + - repo: https://github.com/asottile/seed-isort-config + rev: v1.5.0 + hooks: + - id: seed-isort-config + - repo: https://github.com/pre-commit/mirrors-isort + rev: v4.3.4 + hooks: + - id: isort + - repo: https://github.com/ambv/black + rev: 18.9b0 + hooks: + - id: black + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.1.0 + hooks: + - id: flake8 diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..d3b32430 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,28 @@ +dist: xenial + +language: python +matrix: + include: + - python: 3.4 + - python: 3.5 + - python: 3.6 + env: PYTEST_ADDOPTS='--black' + - python: 3.7 + env: PYTEST_ADDOPTS='--black' + +install: + - pip install . 'black ; python_version>="3.6"' + +script: + - python setup.py test --addopts '--cov=src --cov-report=xml --flake8 --isort' + - bash <(curl -s https://codecov.io/bash) || echo 'Codecov failed to upload' + +deploy: + provider: pypi + user: maxbrunet + password: + secure: h25Z73aqS3t5qTGHU7psnXmG8g2p/BBjjttRycM116/I7KWEame/TwO2scPExzkjNLZiFaWGf2hnc/jJsYI+LmxHlLR9lLK2lQbEehVHeIXuC+5E8vo46aJMTFZHpI9RMAtecGUN1B84IhaXDhDNYLl/jL62HB0HxTwjta6QHeVsJpUPP9IrE3WQq4xgDWzTxWOIK5XTItkFPaTNhuASGQSr3dL+O+Vz84tu7gqRMpIpCw5FWVU4/thm2fq4p5QkL7xHk0FC1Y4wrfZaqhg2Xno8dMtWItUwu69fpJvt+7kd/dqPQnNsjjE7BSLkPKN/i46tJ/jcNMWZ3dgiXqx/d20PmL0xghRaCIfuQ2PXaW9jB0U+TO0VLDntqiqdCx0ZQ8JA99tvUwdbt+PgVV68NMIwTaKh3jpeG72T87l+chpOAQ8v1SNNG1me8PKk1tg4kfJMn7Qy5ckFx2sKyae+zQ4lqRfZZ0One399Dos2/b2Z2QZ9UMRSmkQwpn/hGxZHHqlB76QGUu4AEn8yyDUbDw9bbiEDIlGzUPGi4ytSko9ol+WONZRMKBBxTXUo2KxOikqQrv/AqcFV2bHqzyUHXmK/hWKiVbAANajg2195dHPSxclAnpVorJRR3farInJmIB/ZdYY0PgECL1T6jEpY4c3wTQwKkxAb/GdkYFpqLyg= + distributions: sdist bdist_wheel + on: + tags: true + python: 3.6 diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..22c80d57 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,14 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## 0.1.0 - 2019-01-08 +### Added + +- Initial release + +[Unreleased]: https://github.com/maxbrunet/mmemoji/compare/v0.1.0...HEAD diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..94a9ed02 --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/README.md b/README.md new file mode 100644 index 00000000..ba0d22a9 --- /dev/null +++ b/README.md @@ -0,0 +1,96 @@ +[![PyPI][pypi badge]][pypi link] +[![Build Status][build badge]][build link] +[![codecov][codecov badge]][codecov link] + +# mmemoji + +Custom Emoji manager command-line for [Mattermost][mattermost] 😎 + +Features: + +* Create custom Emojis +* Delete custom Emojis + +Coming soon: + +* List custom Emojis +* Search custom Emojis +* Export custom Emojis + +## Installation + + +```shell +pip install mmemoji +mmemoji --help +``` + +_(Requires Python >=3.4)_ + +## Usage example + +Let's take the [Party Parrot][COTPP] Emojis as an example. + +* First, clone the Git repository or retrieve an archive of it: + +```shell +git clone https://github.com/jmhobbs/cultofthepartyparrot.com.git +cd cultofthepartyparrot.com +``` + +* Then you'll need your Mattermost credentials. You can either pass them to `mmemoji` with the arguments `--url`/`--login-id`/`--password` or via environment variables, for example: + +```shell +export MM_URL='http://127.0.0.1:8065/api/v4' +export MM_LOGIN_ID='user-1@sample.mattermost.com' +export MM_PASSWORD='user-1' +``` + +* Finally, run `mmemoji` to import all the parrots: + +```shell +mmemoji create --no-clobber {parrots,guests}/hd/*.gif {parrots,guests}/*.gif +``` + +_Notes_: + +* Here we rely on [shell globbing][glob] to select all Emoji from the directories. +* Specifying the `hd` directories first with `--no-clobber` ensures these Emojis are created first and not overwritten by their lower quality counterpart. + +## Development + +* You can clone this repository and install the project in editable mode: + +```shell +pip install -e . +``` + +* You'll find a script to create a local [Docker][docker] test instance under `tests/`: + +```shell +./tests/scripts/setup.sh +``` + +* You can run the test suite with: + +```shell +python setup.py test +``` + +* And last thing, you can install the [pre-commit][pre-commit] hooks to help with the formatting of your code. + +```shell +pre-commit install +``` + +[pypi badge]: https://img.shields.io/pypi/v/mmemoji.svg +[pypi link]: https://pypi.python.org/pypi/mmemoji +[build badge]: https://travis-ci.com/maxbrunet/mmemoji.svg +[build link]: https://travis-ci.com/maxbrunet/mmemoji +[codecov badge]: https://codecov.io/gh/maxbrunet/mmemoji/badge.svg +[codecov link]: https://codecov.io/gh/maxbrunet/mmemoji +[mattermost]: https://www.mattermost.org +[COTPP]: https://cultofthepartyparrot.com +[glob]: https://en.wikipedia.org/wiki/Glob_(programming) +[docker]: https://www.docker.com +[pre-commit]: https://pre-commit.com diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..adcceb04 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,21 @@ +[build-system] +requires = ["setuptools", "wheel"] + +[tool.black] +line-length = 79 +py36 = true +include = '\.pyi?$' +exclude = ''' +/( + \.eggs + | \.git + | \.hg + | \.mypy_cache + | \.tox + | \.venv + | _build + | buck-out + | build + | dist +)/ +''' diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 00000000..09c91592 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,18 @@ +[aliases] +test=pytest + +[bdist_wheel] +python-tag = py3 + +[isort] +multi_line_output=3 +include_trailing_comma=True +force_grid_wrap=0 +combine_as_imports=True +line_length=79 +known_third_party=click,mattermostdriver,pytest,requests,setuptools,tablib,tabulate +known_first_party=mmemoji + +[tool:pytest] +addopts = --verbose +testpaths = tests diff --git a/setup.py b/setup.py new file mode 100644 index 00000000..355a00f8 --- /dev/null +++ b/setup.py @@ -0,0 +1,60 @@ +from os import path + +from setuptools import find_packages, setup + +root_dir = path.abspath(path.dirname(__file__)) +src_dir = path.relpath(path.join(root_dir, "src")) + +pkg_info = {} +version_module = path.join(root_dir, "src", "mmemoji", "version.py") +with open(version_module) as f: + exec(f.read(), pkg_info) + +readme_file = path.join(root_dir, "README.md") +with open(readme_file) as f: + readme = f.read() + +setup( + name="mmemoji", + version=pkg_info["VERSION"], + description=pkg_info["DESCRIPTION"], + long_description=readme, + long_description_content_type="text/markdown", + classifiers=[ + "Environment :: Web Environment", + "Intended Audience :: End Users/Desktop", + "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", + "Natural Language :: English", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.4", + "Programming Language :: Python :: 3.5", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Topic :: Utilities", + ], + keywords="cli emoji mattermost", + url="https://github.com/maxbrunet/mmemoji", + license="GPLv3", + package_dir={"": src_dir}, + packages=find_packages(src_dir), + python_requires=">=3.4", + install_requires=[ + "click>=7.0", + "mattermostdriver>=6.1.2", + "requests", + "tablib", + "tabulate", + ], + entry_points={"console_scripts": ["mmemoji = mmemoji.cli:cli"]}, + setup_requires=["pytest-runner"], + tests_require=[ + "pytest", + "pytest-black ; python_version>='3.6'", + "pytest-cov", + "pytest-flake8", + "pytest-isort", + "pytest-vcr", + ], +) diff --git a/src/mmemoji/__init__.py b/src/mmemoji/__init__.py new file mode 100644 index 00000000..a9fbdd44 --- /dev/null +++ b/src/mmemoji/__init__.py @@ -0,0 +1,2 @@ +__all__ = ["Emoji"] +from mmemoji.emoji import Emoji diff --git a/src/mmemoji/cli.py b/src/mmemoji/cli.py new file mode 100644 index 00000000..f0237cab --- /dev/null +++ b/src/mmemoji/cli.py @@ -0,0 +1,34 @@ +import logging +import os + +import click + +from mmemoji.version import DESCRIPTION, VERSION + +logging.getLogger("mattermostdriver.websocket").disabled = True + + +class EmojiCLI(click.MultiCommand): + """Custom Click Command class to dynamically discover subcommands""" + + def list_commands(self, ctx): + rv = [] + cmd_folder = os.path.abspath( + os.path.join(os.path.dirname(__file__), "commands") + ) + for filename in os.listdir(cmd_folder): + if filename.endswith(".py") and not filename == "__init__.py": + rv.append(filename[:-3]) + rv.sort() + return rv + + def get_command(self, ctx, name): + module = __import__("mmemoji.commands." + name, None, None, ["cli"]) + return module.cli + + +@click.command(name="mmemoji", cls=EmojiCLI, help=DESCRIPTION) +@click.version_option(version=VERSION, message="%(prog)s %(version)s") +def cli(): + """CLI entry-point""" + pass diff --git a/src/mmemoji/commands/__init__.py b/src/mmemoji/commands/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/mmemoji/commands/create.py b/src/mmemoji/commands/create.py new file mode 100644 index 00000000..8a65b5d3 --- /dev/null +++ b/src/mmemoji/commands/create.py @@ -0,0 +1,50 @@ +import click +from requests import HTTPError + +from mmemoji import Emoji +from mmemoji.decorators import parse_global_options + + +@click.command(help="Create custom Emojis") +@click.argument("images", type=click.File("rb", lazy=True), nargs=-1) +@click.option( + "-f", + "--force", + is_flag=True, + help=""" +if the emoji exists, remove it and proceed \ +(this option is ignored when the -i or -n option is also used) +""", +) +@click.option( + "-n", + "--no-clobber", + is_flag=True, + help="do not overwrite an existing file (overrides -i option)", +) +@click.option( + "-i", "--interactive", is_flag=True, help="prompt before overwrite" +) +@parse_global_options +def cli(ctx, images, force, no_clobber, interactive): + emojis = [] + + try: + with click.progressbar(images, show_pos=True) as pb_images: + for image in pb_images: + emoji = Emoji(ctx.mattermost, image.name) + + if emoji.emoji and not no_clobber and interactive: + force = click.confirm( + 'overwrite "{}"?'.format(emoji.name), err=True + ) + if not force: + continue + + with image as img: + if emoji.create(img, force, no_clobber): + emojis.append(emoji.emoji) + except HTTPError as e: + raise click.ClickException(e.args if e.args != () else repr(e)) + finally: + ctx.print_dict(emojis) diff --git a/src/mmemoji/commands/delete.py b/src/mmemoji/commands/delete.py new file mode 100644 index 00000000..46b9e641 --- /dev/null +++ b/src/mmemoji/commands/delete.py @@ -0,0 +1,36 @@ +import click +from requests import HTTPError + +from mmemoji import Emoji +from mmemoji.decorators import parse_global_options + + +@click.command(help="Delete custom Emojis") +@click.argument("emoji_names", nargs=-1) +@click.option("-f", "--force", is_flag=True, help="ignore nonexistent files") +@click.option( + "-i", "--interactive", is_flag=True, help="prompt before every removal" +) +@parse_global_options +def cli(ctx, emoji_names, force, interactive): + emojis = [] + try: + with click.progressbar(emoji_names, show_pos=True) as pb_names: + for name in pb_names: + emoji = Emoji(ctx.mattermost, name) + + if ( + interactive + and emoji.emoji + and not click.confirm( + 'delete "{}"?'.format(emoji.name), err=True + ) + ): + continue + + if emoji.delete(force): + emojis.append(emoji.emoji) + except HTTPError as e: + raise click.ClickException(e.args if e.args != () else repr(e)) + finally: + ctx.print_dict(emojis) diff --git a/src/mmemoji/decorators.py b/src/mmemoji/decorators.py new file mode 100644 index 00000000..a5daf936 --- /dev/null +++ b/src/mmemoji/decorators.py @@ -0,0 +1,206 @@ +from contextlib import contextmanager +from functools import wraps +from urllib.parse import urlparse + +import click +import requests.exceptions +from mattermostdriver import Driver as Mattermost +from mattermostdriver.exceptions import MethodNotAllowed +from tablib import Dataset +from tabulate import tabulate + + +def validate_url(ctx, param, value): + """Ensure URL contains minimum information to be used""" + url = urlparse(value) + if not url.scheme or not url.hostname: + raise click.BadParameter("Malformed URL: {}".format(value)) + return url + + +def compose(*decorators): + """Merge multiple decorators into a single one""" + + def decorate(func): + for decorator in reversed(decorators): + func = decorator(func) + return func + + return decorate + + +global_options = compose( + click.option( + "-u", + "--url", + metavar="URL", + envvar="MM_URL", + callback=validate_url, + required=True, + help=""" + Mattermost APIv4 URL (e.g http://localhost:8065/api/v4) (env: MM_URL) + """, + ), + click.option( + "-t", + "--token", + metavar="TOKEN", + envvar="MM_TOKEN", + help=""" + Personal Access Token (env: MM_TOKEN) + """, + ), + click.option( + "-l", + "--login-id", + metavar="LOGIN_ID", + envvar="MM_LOGIN_ID", + help=""" + login ID to use in conjunction with a password (env: MM_LOGIN_ID) + """, + ), + click.option( + "-P", + "--password", + metavar="PASSWORD", + envvar="MM_PASSWORD", + help=""" + password to use in conjunction with a login ID (env: MM_PASSWORD) + """, + ), + click.option( + "-m", + "--mfa-token", + metavar="MFA_TOKEN", + envvar="MM_MFA_TOKEN", + help=""" + optionally, Multi-Factor Authentication Token \ + to use in conjunction with login ID/password (env: MM_MFA_TOKEN) + """, + ), + click.option( + "-k", + "--insecure", + envvar="MM_INSECURE", + is_flag=True, + help=""" + allow insecure server connections when using SSL (env: MM_INSECURE) + """, + ), + click.option( + "--output", + "-o", + type=click.Choice(["csv", "json", "table", "yaml"]), + default="table", + help="output format (default: table)", + ), +) + + +# Workaround for the help option of subcommands not being eager enough +# The parent command is executed anyway +# https://github.com/pallets/click/issues/295 +# https://github.com/pallets/click/issues/814 +# This moves all global options to the subcommand which isn't that bad +# This way all options are visible when asking for help on a subcommand +def parse_global_options(func): + """Parse options used by every commands such as auth and output format""" + + @wraps(global_options(func)) + @pass_context + def wrapper(*args, **kwargs): + ctx = args[0] + ctx.output = kwargs.pop("output") + with ctx.authenticate( + kwargs.pop("url"), + kwargs.pop("token"), + kwargs.pop("login_id"), + kwargs.pop("password"), + kwargs.pop("mfa_token"), + kwargs.pop("insecure"), + ): + return func(*args, **kwargs) + + return wrapper + + +class EmojiContext: + """ + Custom Click Context class + to store global settings and manage authentication + """ + + def __init__(self): + self.output = "table" + self.mattermost = None + + @contextmanager + def authenticate( + self, url, token, login_id, password, mfa_token, insecure + ): + """Authenticate against the Mattermost server""" + + if token and (login_id or password or mfa_token): + click.echo( + """\ +Warning: Token specified along with Login-ID/Password/MFA-token. \ +Only Token will be used.""", + err=True, + ) + + settings = { + "scheme": url.scheme, + "url": url.hostname, + "basepath": getattr(url, "path", ""), + "verify": not insecure, + "login_id": login_id, + "password": password, + "token": token, + "mfa_token": mfa_token, + } + + if url.port: + settings["port"] = url.port + elif url.scheme == "https": + settings["port"] = 443 + else: + settings["port"] = 80 + + self.mattermost = Mattermost(settings) + try: + try: + yield self.mattermost.login() + finally: + # Logout is unnecessary if token was used + if token is None: + self.mattermost.logout() + except (requests.exceptions.ConnectionError, MethodNotAllowed): + raise click.ClickException( + "Unable to reach Mattermost API at {}".format( + self.mattermost.client.url + ) + ) + except requests.exceptions.HTTPError as e: + raise click.ClickException(e.args if e.args != () else repr(e)) + + def print_dict(self, data): + """Print dataset generated by a command to the standard output""" + dataset = Dataset() + dataset.dict = data + if dataset.height: + if self.output == "table": + click.echo(tabulate(dataset.dict, headers="keys")) + else: + # we will probably implement JSON output only in the long run + # and get rid of the `tablib` dependency + click.echo(dataset.export(self.output)) + + click.echo( + "\n({} emoji{})".format( + dataset.height, "" if dataset.height == 1 else "s" + ), + err=True, + ) + + +pass_context = click.make_pass_decorator(EmojiContext, ensure=True) diff --git a/src/mmemoji/emoji.py b/src/mmemoji/emoji.py new file mode 100644 index 00000000..e36b3ae7 --- /dev/null +++ b/src/mmemoji/emoji.py @@ -0,0 +1,139 @@ +"""Wrapper for Mattermost API ``/emoji`` Endpoint. + +This wrapper is built around ``python-mattermostdriver``_ + +.. _python-mattermostdriver: + https://vaelor.github.io/python-mattermost-driver/ +""" + +import re +from os.path import basename + +from mattermostdriver.exceptions import ResourceNotFound + +from mmemoji.exceptions import EmojiAlreadyExists, EmojiNotFound + + +class Emoji: + """Interact with Mattermost custom Emojis.""" + + def __init__(self, mattermost, name): + """Init Emoji class with a Mattermost client instance and an Emoji name. + + Parameters + ---------- + mattermost : :obj:`mattermostdriver.Driver` + an instance of `mattermostdriver`_ + name : str + an Emoji name. It can be a file path, + the filename will be automatically extracted and sanitized + """ + self._mm = mattermost + self._name = self.sanitize_name(name) + self._emoji = {} + + @staticmethod + def sanitize_name(filepath): + """Extract and sanitize an Emoji name from a file path. + + Parameters + ---------- + filepath : str + Emoji file path (e.g. ``/path/to/emoji (1).gif``) + + Returns + ------- + str + Emoji name (e.g. ``emoji_1``) + """ + # Extract filename without extension + name = basename(filepath).split(".")[0] + # Remove parentheses + name = re.sub(r"[()[\]{}]", "", name) + # Replace forbidden characters by underscores + name = re.sub(r"[^a-zA-Z0-9_-]", "_", name) + return name + + def _get_from_mattermost(self): + """Retrieve custom Emoji information from Mattermost.""" + try: + self._emoji = self._mm.emoji.get_custom_emoji_by_name(self.name) + return True + except ResourceNotFound: + self._emoji = {} + return False + + @property + def emoji(self): + """:obj:`dict` of (str: str): Gets Emoji information.""" + if not self._emoji: + self._get_from_mattermost() + return self._emoji + + @property + def name(self): + """str: Get Emoji name.""" + return self._name + + def create(self, image, force=False, no_clobber=False): + """Create a custom Emoji on Mattermost. + + Parameters + ---------- + image : :obj:`file` + an image to upload + force: bool + delete Emoji if it already exits + (ignored if ``no_clobber is ``True``) + no_clobber: bool + do nothing if Emoji already exits + + Returns + ------- + bool + Returns ``True`` if Emoji was created + + Raises + ------ + EmojiAlreadyExists + If nor ``no_clobber`` or ``force`` were ``True`` + """ + if self.emoji: + if no_clobber: + return False + elif force: + self.delete() + else: + raise EmojiAlreadyExists(self) + + self._emoji = self._mm.emoji.create_custom_emoji( + emoji_name=self._name, files={"image": image} + ) + return True + + def delete(self, force=False): + """Delete a custom Emoji on Mattermost. + + Parameters + ---------- + force: bool + Ignore non-existent Emoji + + Returns + ------- + bool + Returns ``True`` if Emoji was deleted + + Raises + ------ + EmojiNotFound + If Emoji does not exist and ``force`` was not ``True`` + """ + if not self.emoji and force: + return False + + if self.emoji: + self._mm.emoji.delete_custom_emoji(self.emoji.get("id", "")) + return True + else: + raise EmojiNotFound(self) diff --git a/src/mmemoji/exceptions.py b/src/mmemoji/exceptions.py new file mode 100644 index 00000000..06e6ff35 --- /dev/null +++ b/src/mmemoji/exceptions.py @@ -0,0 +1,18 @@ +from mattermostdriver.exceptions import ( + InvalidOrMissingParameters, + ResourceNotFound, +) + + +class EmojiNotFound(ResourceNotFound): + """Raised when an Emoji is not found on the Mattermost server""" + + def __init__(self, emoji): + super().__init__('Emoji "{}" does not exist'.format(emoji.name)) + + +class EmojiAlreadyExists(InvalidOrMissingParameters): + """Raised when an Emoji already exists on the Mattermost server""" + + def __init__(self, emoji): + super().__init__('Emoji "{}" exists'.format(emoji.name)) diff --git a/src/mmemoji/version.py b/src/mmemoji/version.py new file mode 100644 index 00000000..94a862f9 --- /dev/null +++ b/src/mmemoji/version.py @@ -0,0 +1,2 @@ +VERSION = "0.1.0" +DESCRIPTION = "Custom Emoji manager command-line for Mattermost 😎" diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/cassettes/test_create_emoji.yaml b/tests/cassettes/test_create_emoji.yaml new file mode 100644 index 00000000..c3e6b675 --- /dev/null +++ b/tests/cassettes/test_create_emoji.yaml @@ -0,0 +1,229 @@ +interactions: +- request: + body: '{"login_id": "user-1@sample.mattermost.com", "password": "user-1", "token": + null}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Connection: [keep-alive] + Content-Length: ['81'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/login + response: + body: {string: '{"id":"jjcp4yj9gtr7bdfj43s7ukfh6w","create_at":1545253049270,"update_at":1545253049270,"delete_at":0,"username":"user-1","auth_data":"","auth_service":"","email":"user-1@sample.mattermost.com","email_verified":true,"nickname":"","first_name":"Victor","last_name":"Welch","position":"Design + Engineer","roles":"system_user","notify_props":{"channel":"true","comments":"never","desktop":"mention","desktop_sound":"true","email":"true","first_name":"false","mention_keys":",@","push":"mention","push_status":"away"},"last_password_update":1545253049270,"locale":"en","timezone":{"automaticTimezone":"","manualTimezone":"","useAutomaticTimezone":"true"}}'} + headers: + Content-Length: ['649'] + Content-Type: [application/json] + Date: ['Thu, 20 Dec 2018 22:28:20 GMT'] + Set-Cookie: ['MMAUTHTOKEN=kpejhex6gjdoicajrq78jsq74e; Path=/; Expires=Sat, 19 + Jan 2019 22:28:20 GMT; Max-Age=2592000; HttpOnly', 'MMUSERID=jjcp4yj9gtr7bdfj43s7ukfh6w; + Path=/; Expires=Sat, 19 Jan 2019 22:28:20 GMT; Max-Age=2592000'] + Token: [kpejhex6gjdoicajrq78jsq74e] + X-Request-Id: [cq6tjyg77jbfuxhufi7c47zfdh] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer kpejhex6gjdoicajrq78jsq74e] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: GET + uri: http://localhost:8065/api/v4/emoji/name/emoji_1 + response: + body: {string: '{"id":"store.sql_emoji.get_by_name.app_error","message":"Unable + to get the emoji","detailed_error":"","request_id":"1d9z7mudpjbrmd9pzt4swa8nuh","status_code":404}'} + headers: + Content-Length: ['162'] + Content-Type: [application/json] + Date: ['Thu, 20 Dec 2018 22:28:20 GMT'] + Expires: ['0'] + X-Request-Id: [1d9z7mudpjbrmd9pzt4swa8nuh] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 404, message: Not Found} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer kpejhex6gjdoicajrq78jsq74e] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: GET + uri: http://localhost:8065/api/v4/emoji/name/emoji_1 + response: + body: {string: '{"id":"store.sql_emoji.get_by_name.app_error","message":"Unable + to get the emoji","detailed_error":"","request_id":"i4wnmm3yejyppq7ap73fefjttc","status_code":404}'} + headers: + Content-Length: ['162'] + Content-Type: [application/json] + Date: ['Thu, 20 Dec 2018 22:28:20 GMT'] + Expires: ['0'] + X-Request-Id: [i4wnmm3yejyppq7ap73fefjttc] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 404, message: Not Found} +- request: + body: !!binary | + LS02MjRmMWM4NGRmNWEwMzQ1ODBhYTNmZWJmOTRiNDU3ZA0KQ29udGVudC1EaXNwb3NpdGlvbjog + Zm9ybS1kYXRhOyBuYW1lPSJlbW9qaSINCg0KeyJuYW1lIjogImVtb2ppXzEiLCAiY3JlYXRvcl9p + ZCI6ICJqamNwNHlqOWd0cjdiZGZqNDNzN3VrZmg2dyJ9DQotLTYyNGYxYzg0ZGY1YTAzNDU4MGFh + M2ZlYmY5NGI0NTdkDQpDb250ZW50LURpc3Bvc2l0aW9uOiBmb3JtLWRhdGE7IG5hbWU9ImltYWdl + IjsgZmlsZW5hbWU9ImVtb2ppXzEucG5nIg0KDQqJUE5HDQoaCgAAAA1JSERSAAAAgAAAAIAIBgAA + AMM+YcsAAAAG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AAAASUVORK5CYIINCi0tNjI0ZjFjODRkZjVhMDM0NTgwYWEzZmVi + Zjk0YjQ1N2QtLQ0K + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer kpejhex6gjdoicajrq78jsq74e] + Connection: [keep-alive] + Content-Length: ['1152'] + Content-Type: [multipart/form-data; boundary=624f1c84df5a034580aa3febf94b457d] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/emoji + response: + body: {string: '{"id":"ppwiu6okujyfueay7a3exhtdwo","create_at":1545344900375,"update_at":1545344900375,"delete_at":0,"creator_id":"jjcp4yj9gtr7bdfj43s7ukfh6w","name":"emoji_1"}'} + headers: + Content-Length: ['160'] + Content-Type: [application/json] + Date: ['Thu, 20 Dec 2018 22:28:20 GMT'] + X-Request-Id: [zqfbwgncg38mj81k9p8sos8khh] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{"login_id": "user-1@sample.mattermost.com", "password": "user-1", "token": + null}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Connection: [keep-alive] + Content-Length: ['81'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/login + response: + body: {string: '{"id":"jjcp4yj9gtr7bdfj43s7ukfh6w","create_at":1545253049270,"update_at":1545253049270,"delete_at":0,"username":"user-1","auth_data":"","auth_service":"","email":"user-1@sample.mattermost.com","email_verified":true,"nickname":"","first_name":"Victor","last_name":"Welch","position":"Design + Engineer","roles":"system_user","notify_props":{"channel":"true","comments":"never","desktop":"mention","desktop_sound":"true","email":"true","first_name":"false","mention_keys":",@","push":"mention","push_status":"away"},"last_password_update":1545253049270,"locale":"en","timezone":{"automaticTimezone":"","manualTimezone":"","useAutomaticTimezone":"true"}}'} + headers: + Content-Length: ['649'] + Content-Type: [application/json] + Date: ['Thu, 20 Dec 2018 22:28:20 GMT'] + Set-Cookie: ['MMAUTHTOKEN=5wjgtnwq6igh7er1w5wxnzn73c; Path=/; Expires=Sat, 19 + Jan 2019 22:28:20 GMT; Max-Age=2592000; HttpOnly', 'MMUSERID=jjcp4yj9gtr7bdfj43s7ukfh6w; + Path=/; Expires=Sat, 19 Jan 2019 22:28:20 GMT; Max-Age=2592000'] + Token: [5wjgtnwq6igh7er1w5wxnzn73c] + X-Request-Id: [r3nqxh7453bh9brjy14durj86w] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer 5wjgtnwq6igh7er1w5wxnzn73c] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: GET + uri: http://localhost:8065/api/v4/emoji/name/emoji_1 + response: + body: {string: '{"id":"ppwiu6okujyfueay7a3exhtdwo","create_at":1545344900375,"update_at":1545344900375,"delete_at":0,"creator_id":"jjcp4yj9gtr7bdfj43s7ukfh6w","name":"emoji_1"}'} + headers: + Content-Length: ['160'] + Content-Type: [application/json] + Date: ['Thu, 20 Dec 2018 22:28:20 GMT'] + Expires: ['0'] + X-Request-Id: [76iuzmsrp7rrudwzdesqgi1kwc] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer 5wjgtnwq6igh7er1w5wxnzn73c] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: DELETE + uri: http://localhost:8065/api/v4/emoji/ppwiu6okujyfueay7a3exhtdwo + response: + body: {string: '{"status":"OK"}'} + headers: + Content-Length: ['15'] + Content-Type: [application/json] + Date: ['Thu, 20 Dec 2018 22:28:20 GMT'] + X-Request-Id: [bamukjn18jnwpnqjp9pjm68qwe] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer 5wjgtnwq6igh7er1w5wxnzn73c] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/logout + response: + body: {string: '{"status":"OK"}'} + headers: + Content-Length: ['15'] + Content-Type: [application/json] + Date: ['Thu, 20 Dec 2018 22:28:20 GMT'] + Set-Cookie: [MMAUTHTOKEN=; Path=/; Max-Age=0; HttpOnly] + X-Request-Id: [1eq76xck63d9mmp1gbj61hxgwh] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer 5wjgtnwq6igh7er1w5wxnzn73c] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/logout + response: + body: {string: '{"status":"OK"}'} + headers: + Content-Length: ['15'] + Content-Type: [application/json] + Date: ['Tue, 08 Jan 2019 20:29:36 GMT'] + Set-Cookie: [MMAUTHTOKEN=; Path=/; Max-Age=0; HttpOnly] + X-Request-Id: [trzxbxxbjfnmdrq5zyeat917zh] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +version: 1 diff --git a/tests/cassettes/test_create_exiting_emoji.yaml b/tests/cassettes/test_create_exiting_emoji.yaml new file mode 100644 index 00000000..b8b49502 --- /dev/null +++ b/tests/cassettes/test_create_exiting_emoji.yaml @@ -0,0 +1,253 @@ +interactions: +- request: + body: '{"login_id": "user-1@sample.mattermost.com", "password": "user-1", "token": + null}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Connection: [keep-alive] + Content-Length: ['81'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/login + response: + body: {string: '{"id":"jjcp4yj9gtr7bdfj43s7ukfh6w","create_at":1545253049270,"update_at":1545253049270,"delete_at":0,"username":"user-1","auth_data":"","auth_service":"","email":"user-1@sample.mattermost.com","email_verified":true,"nickname":"","first_name":"Victor","last_name":"Welch","position":"Design + Engineer","roles":"system_user","notify_props":{"channel":"true","comments":"never","desktop":"mention","desktop_sound":"true","email":"true","first_name":"false","mention_keys":",@","push":"mention","push_status":"away"},"last_password_update":1545253049270,"locale":"en","timezone":{"automaticTimezone":"","manualTimezone":"","useAutomaticTimezone":"true"}}'} + headers: + Content-Length: ['649'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 20:26:44 GMT'] + Set-Cookie: ['MMAUTHTOKEN=awaxm6epi3r43e5oh4igbcgcbh; Path=/; Expires=Tue, 05 + Feb 2019 20:26:44 GMT; Max-Age=2592000; HttpOnly', 'MMUSERID=jjcp4yj9gtr7bdfj43s7ukfh6w; + Path=/; Expires=Tue, 05 Feb 2019 20:26:44 GMT; Max-Age=2592000'] + Token: [awaxm6epi3r43e5oh4igbcgcbh] + X-Request-Id: [kg988bbhc7rizqpgyw85r8otmy] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: !!binary | + LS1iODE5NTFhYTEyMGEyMzdmMGMzOThkMDk5MGM4OWVlYQ0KQ29udGVudC1EaXNwb3NpdGlvbjog + Zm9ybS1kYXRhOyBuYW1lPSJlbW9qaSINCg0KeyJuYW1lIjogImVtb2ppXzEiLCAiY3JlYXRvcl9p + ZCI6ICJqamNwNHlqOWd0cjdiZGZqNDNzN3VrZmg2dyJ9DQotLWI4MT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AGoAFQAKgAVgApABSAAFYAK + QAWgAlABqABUACoAFYAKQAWgAlABqABUACoAFYAKQAWgAlABqABUACoAFYAKQAWgAlABqABUACoA + FYAKQAWgZtjaOv2dB3HxTJ7zzpP8uZuwdSaP+fn/a8Nb1ukJHML17W/zm1OngNYAFYAKQAWgAlAB + qABUVVXVpu9PAg9fbpqJaG8AAAAASUVORK5CYIINCi0tYjgxOTUxYWExMjBhMjM3ZjBjMzk4ZDA5 + OTBjODllZWEtLQ0K + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer awaxm6epi3r43e5oh4igbcgcbh] + Connection: [keep-alive] + Content-Length: ['1152'] + Content-Type: [multipart/form-data; boundary=b81951aa120a237f0c398d0990c89eea] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/emoji + response: + body: {string: '{"id":"pbmbfxxfpbyfjpxu1y7cweir5c","create_at":1546806404075,"update_at":1546806404075,"delete_at":0,"creator_id":"jjcp4yj9gtr7bdfj43s7ukfh6w","name":"emoji_1"}'} + headers: + Content-Length: ['160'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 20:26:44 GMT'] + X-Request-Id: [hkegaenfpidtzd7iz8dgzuszda] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer awaxm6epi3r43e5oh4igbcgcbh] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/logout + response: + body: {string: '{"status":"OK"}'} + headers: + Content-Length: ['15'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 20:26:44 GMT'] + Set-Cookie: [MMAUTHTOKEN=; Path=/; Max-Age=0; HttpOnly] + X-Request-Id: [rpjpg7c5x3f8djsq9to8iitpuh] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{"login_id": "user-1@sample.mattermost.com", "password": "user-1", "token": + null}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Connection: [keep-alive] + Content-Length: ['81'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/login + response: + body: {string: '{"id":"jjcp4yj9gtr7bdfj43s7ukfh6w","create_at":1545253049270,"update_at":1545253049270,"delete_at":0,"username":"user-1","auth_data":"","auth_service":"","email":"user-1@sample.mattermost.com","email_verified":true,"nickname":"","first_name":"Victor","last_name":"Welch","position":"Design + Engineer","roles":"system_user","notify_props":{"channel":"true","comments":"never","desktop":"mention","desktop_sound":"true","email":"true","first_name":"false","mention_keys":",@","push":"mention","push_status":"away"},"last_password_update":1545253049270,"locale":"en","timezone":{"automaticTimezone":"","manualTimezone":"","useAutomaticTimezone":"true"}}'} + headers: + Content-Length: ['649'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 20:26:44 GMT'] + Set-Cookie: ['MMAUTHTOKEN=3o89dq1wu38o7xum4hnmd7e9ce; Path=/; Expires=Tue, 05 + Feb 2019 20:26:44 GMT; Max-Age=2592000; HttpOnly', 'MMUSERID=jjcp4yj9gtr7bdfj43s7ukfh6w; + Path=/; Expires=Tue, 05 Feb 2019 20:26:44 GMT; Max-Age=2592000'] + Token: [3o89dq1wu38o7xum4hnmd7e9ce] + X-Request-Id: [egjjuxjiof87zfrr3wpk3h4pjy] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer 3o89dq1wu38o7xum4hnmd7e9ce] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: GET + uri: http://localhost:8065/api/v4/emoji/name/emoji_1 + response: + body: {string: '{"id":"pbmbfxxfpbyfjpxu1y7cweir5c","create_at":1546806404075,"update_at":1546806404075,"delete_at":0,"creator_id":"jjcp4yj9gtr7bdfj43s7ukfh6w","name":"emoji_1"}'} + headers: + Content-Length: ['160'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 20:26:44 GMT'] + Expires: ['0'] + X-Request-Id: [4x6mr3be7pg38e6d5oh1jjwm7h] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{"login_id": "user-1@sample.mattermost.com", "password": "user-1", "token": + null}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Connection: [keep-alive] + Content-Length: ['81'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/login + response: + body: {string: '{"id":"jjcp4yj9gtr7bdfj43s7ukfh6w","create_at":1545253049270,"update_at":1545253049270,"delete_at":0,"username":"user-1","auth_data":"","auth_service":"","email":"user-1@sample.mattermost.com","email_verified":true,"nickname":"","first_name":"Victor","last_name":"Welch","position":"Design + Engineer","roles":"system_user","notify_props":{"channel":"true","comments":"never","desktop":"mention","desktop_sound":"true","email":"true","first_name":"false","mention_keys":",@","push":"mention","push_status":"away"},"last_password_update":1545253049270,"locale":"en","timezone":{"automaticTimezone":"","manualTimezone":"","useAutomaticTimezone":"true"}}'} + headers: + Content-Length: ['649'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 20:26:44 GMT'] + Set-Cookie: ['MMAUTHTOKEN=zoudpkjqujrrtc77kqucnyf5ir; Path=/; Expires=Tue, 05 + Feb 2019 20:26:44 GMT; Max-Age=2592000; HttpOnly', 'MMUSERID=jjcp4yj9gtr7bdfj43s7ukfh6w; + Path=/; Expires=Tue, 05 Feb 2019 20:26:44 GMT; Max-Age=2592000'] + Token: [zoudpkjqujrrtc77kqucnyf5ir] + X-Request-Id: [qeruqshxsb8gdj98gwsnxugyzy] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer zoudpkjqujrrtc77kqucnyf5ir] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: GET + uri: http://localhost:8065/api/v4/emoji/name/emoji_1 + response: + body: {string: '{"id":"pbmbfxxfpbyfjpxu1y7cweir5c","create_at":1546806404075,"update_at":1546806404075,"delete_at":0,"creator_id":"jjcp4yj9gtr7bdfj43s7ukfh6w","name":"emoji_1"}'} + headers: + Content-Length: ['160'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 20:26:44 GMT'] + Expires: ['0'] + X-Request-Id: [ijhf3qq5d7fstrmfuhqqhud3hy] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer zoudpkjqujrrtc77kqucnyf5ir] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: DELETE + uri: http://localhost:8065/api/v4/emoji/pbmbfxxfpbyfjpxu1y7cweir5c + response: + body: {string: '{"status":"OK"}'} + headers: + Content-Length: ['15'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 20:26:44 GMT'] + X-Request-Id: [6dxn7rw58f8wini55osari3kga] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer zoudpkjqujrrtc77kqucnyf5ir] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/logout + response: + body: {string: '{"status":"OK"}'} + headers: + Content-Length: ['15'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 20:26:44 GMT'] + Set-Cookie: [MMAUTHTOKEN=; Path=/; Max-Age=0; HttpOnly] + X-Request-Id: [uj4y6a96ifr38rdnpz9wfrroaw] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer zoudpkjqujrrtc77kqucnyf5ir] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/logout + response: + body: {string: '{"status":"OK"}'} + headers: + Content-Length: ['15'] + Content-Type: [application/json] + Date: ['Tue, 08 Jan 2019 20:29:37 GMT'] + Set-Cookie: [MMAUTHTOKEN=; Path=/; Max-Age=0; HttpOnly] + X-Request-Id: [fdhn3xon7783pd7yi1pwypbgza] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +version: 1 diff --git a/tests/cassettes/test_delete_absent_emoji.yaml b/tests/cassettes/test_delete_absent_emoji.yaml new file mode 100644 index 00000000..611f4071 --- /dev/null +++ b/tests/cassettes/test_delete_absent_emoji.yaml @@ -0,0 +1,96 @@ +interactions: +- request: + body: '{"login_id": "user-1@sample.mattermost.com", "password": "user-1", "token": + null}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Connection: [keep-alive] + Content-Length: ['81'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/login + response: + body: {string: '{"id":"jjcp4yj9gtr7bdfj43s7ukfh6w","create_at":1545253049270,"update_at":1545253049270,"delete_at":0,"username":"user-1","auth_data":"","auth_service":"","email":"user-1@sample.mattermost.com","email_verified":true,"nickname":"","first_name":"Victor","last_name":"Welch","position":"Design + Engineer","roles":"system_user","notify_props":{"channel":"true","comments":"never","desktop":"mention","desktop_sound":"true","email":"true","first_name":"false","mention_keys":",@","push":"mention","push_status":"away"},"last_password_update":1545253049270,"locale":"en","timezone":{"automaticTimezone":"","manualTimezone":"","useAutomaticTimezone":"true"}}'} + headers: + Content-Length: ['649'] + Content-Type: [application/json] + Date: ['Thu, 20 Dec 2018 22:05:03 GMT'] + Set-Cookie: ['MMAUTHTOKEN=j3uz1zjq1fnqtgt6mac7gmpwih; Path=/; Expires=Sat, 19 + Jan 2019 22:05:03 GMT; Max-Age=2592000; HttpOnly', 'MMUSERID=jjcp4yj9gtr7bdfj43s7ukfh6w; + Path=/; Expires=Sat, 19 Jan 2019 22:05:03 GMT; Max-Age=2592000'] + Token: [j3uz1zjq1fnqtgt6mac7gmpwih] + X-Request-Id: [zk14j859s7nk3qunmfgbo4x3ye] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer j3uz1zjq1fnqtgt6mac7gmpwih] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: GET + uri: http://localhost:8065/api/v4/emoji/name/absent_emoji + response: + body: {string: '{"id":"store.sql_emoji.get_by_name.app_error","message":"Unable + to get the emoji","detailed_error":"","request_id":"zsebgtybgfbj9yprw8e7dpbz3r","status_code":404}'} + headers: + Content-Length: ['162'] + Content-Type: [application/json] + Date: ['Thu, 20 Dec 2018 22:05:03 GMT'] + Expires: ['0'] + X-Request-Id: [zsebgtybgfbj9yprw8e7dpbz3r] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 404, message: Not Found} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer j3uz1zjq1fnqtgt6mac7gmpwih] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: GET + uri: http://localhost:8065/api/v4/emoji/name/absent_emoji + response: + body: {string: '{"id":"store.sql_emoji.get_by_name.app_error","message":"Unable + to get the emoji","detailed_error":"","request_id":"ai6jme6y1bg5jjxpxufpr6waqc","status_code":404}'} + headers: + Content-Length: ['162'] + Content-Type: [application/json] + Date: ['Thu, 20 Dec 2018 22:05:03 GMT'] + Expires: ['0'] + X-Request-Id: [ai6jme6y1bg5jjxpxufpr6waqc] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 404, message: Not Found} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer j3uz1zjq1fnqtgt6mac7gmpwih] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/logout + response: + body: {string: '{"status":"OK"}'} + headers: + Content-Length: ['15'] + Content-Type: [application/json] + Date: ['Tue, 08 Jan 2019 20:29:38 GMT'] + Set-Cookie: [MMAUTHTOKEN=; Path=/; Max-Age=0; HttpOnly] + X-Request-Id: [msweh9fn7ifu7kdg8tkmidxgkw] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +version: 1 diff --git a/tests/cassettes/test_delete_emoji.yaml b/tests/cassettes/test_delete_emoji.yaml new file mode 100644 index 00000000..6a99a66b --- /dev/null +++ b/tests/cassettes/test_delete_emoji.yaml @@ -0,0 +1,183 @@ +interactions: +- request: + body: '{"login_id": "user-1@sample.mattermost.com", "password": "user-1", "token": + null}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Connection: [keep-alive] + Content-Length: ['81'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/login + response: + body: {string: '{"id":"jjcp4yj9gtr7bdfj43s7ukfh6w","create_at":1545253049270,"update_at":1545253049270,"delete_at":0,"username":"user-1","auth_data":"","auth_service":"","email":"user-1@sample.mattermost.com","email_verified":true,"nickname":"","first_name":"Victor","last_name":"Welch","position":"Design + Engineer","roles":"system_user","notify_props":{"channel":"true","comments":"never","desktop":"mention","desktop_sound":"true","email":"true","first_name":"false","mention_keys":",@","push":"mention","push_status":"away"},"last_password_update":1545253049270,"locale":"en","timezone":{"automaticTimezone":"","manualTimezone":"","useAutomaticTimezone":"true"}}'} + headers: + Content-Length: ['649'] + Content-Type: [application/json] + Date: ['Thu, 20 Dec 2018 22:05:19 GMT'] + Set-Cookie: ['MMAUTHTOKEN=1y158sm48tgsb8iiniw6w68zdh; Path=/; Expires=Sat, 19 + Jan 2019 22:05:19 GMT; Max-Age=2592000; HttpOnly', 'MMUSERID=jjcp4yj9gtr7bdfj43s7ukfh6w; + Path=/; Expires=Sat, 19 Jan 2019 22:05:19 GMT; Max-Age=2592000'] + Token: [1y158sm48tgsb8iiniw6w68zdh] + X-Request-Id: [46qw6mws67ypijan8m6xxg74zh] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: !!binary | + LS0zMDM1NzA0N2FlZjc1ODJhYjg0OWRjODgzODk0MDdmMQ0KQ29udGVudC1EaXNwb3NpdGlvbjog + Zm9ybS1kYXRhOyBuYW1lPSJlbW9qaSINCg0KeyJuYW1lIjogImVtb2ppXzEiLCAiY3JlYXRvcl9p + ZCI6ICJqamNwNHlqOWd0cjdiZGZqNDNzN3VrZmg2dyJ9DQotLTMwMzU3MDQ3YWVmNzU4MmFiODQ5 + ZGM4ODM4OTQw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AKQAWgAlABqABUACoAFYAKQAWgAlABqABUACoAFYAKQAWgAlABqABUACoA + FYAKQAWgZtjaOv2dB3HxTJ7zzpP8uZuwdSaP+fn/a8Nb1ukJHML17W/zm1OngNYAFYAKQAWgAlAB + qABUVVXVpu9PAg9fbpqJaG8AAAAASUVORK5CYIINCi0tMzAzNTcwNDdhZWY3NTgyYWI4NDlkYzg4 + Mzg5NDA3ZjEtLQ0K + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer 1y158sm48tgsb8iiniw6w68zdh] + Connection: [keep-alive] + Content-Length: ['1152'] + Content-Type: [multipart/form-data; boundary=30357047aef7582ab849dc88389407f1] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/emoji + response: + body: {string: '{"id":"1b4i1w5j8p85irmfx1ddcmr11y","create_at":1545343519341,"update_at":1545343519341,"delete_at":0,"creator_id":"jjcp4yj9gtr7bdfj43s7ukfh6w","name":"emoji_1"}'} + headers: + Content-Length: ['160'] + Content-Type: [application/json] + Date: ['Thu, 20 Dec 2018 22:05:19 GMT'] + X-Request-Id: [xg3o7xxfcjr7xq5ajpn4se4yxw] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer 1y158sm48tgsb8iiniw6w68zdh] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/logout + response: + body: {string: '{"status":"OK"}'} + headers: + Content-Length: ['15'] + Content-Type: [application/json] + Date: ['Thu, 20 Dec 2018 22:05:19 GMT'] + Set-Cookie: [MMAUTHTOKEN=; Path=/; Max-Age=0; HttpOnly] + X-Request-Id: [z43wbjfohbbsidu8h4bqkcgf4w] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{"login_id": "user-1@sample.mattermost.com", "password": "user-1", "token": + null}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Connection: [keep-alive] + Content-Length: ['81'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/login + response: + body: {string: '{"id":"jjcp4yj9gtr7bdfj43s7ukfh6w","create_at":1545253049270,"update_at":1545253049270,"delete_at":0,"username":"user-1","auth_data":"","auth_service":"","email":"user-1@sample.mattermost.com","email_verified":true,"nickname":"","first_name":"Victor","last_name":"Welch","position":"Design + Engineer","roles":"system_user","notify_props":{"channel":"true","comments":"never","desktop":"mention","desktop_sound":"true","email":"true","first_name":"false","mention_keys":",@","push":"mention","push_status":"away"},"last_password_update":1545253049270,"locale":"en","timezone":{"automaticTimezone":"","manualTimezone":"","useAutomaticTimezone":"true"}}'} + headers: + Content-Length: ['649'] + Content-Type: [application/json] + Date: ['Thu, 20 Dec 2018 22:05:19 GMT'] + Set-Cookie: ['MMAUTHTOKEN=wcpukqnp3tr4pg9g8otsh1iufw; Path=/; Expires=Sat, 19 + Jan 2019 22:05:19 GMT; Max-Age=2592000; HttpOnly', 'MMUSERID=jjcp4yj9gtr7bdfj43s7ukfh6w; + Path=/; Expires=Sat, 19 Jan 2019 22:05:19 GMT; Max-Age=2592000'] + Token: [wcpukqnp3tr4pg9g8otsh1iufw] + X-Request-Id: [ohbowryqrigodei18z8z4coyur] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer wcpukqnp3tr4pg9g8otsh1iufw] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: GET + uri: http://localhost:8065/api/v4/emoji/name/emoji_1 + response: + body: {string: '{"id":"1b4i1w5j8p85irmfx1ddcmr11y","create_at":1545343519341,"update_at":1545343519341,"delete_at":0,"creator_id":"jjcp4yj9gtr7bdfj43s7ukfh6w","name":"emoji_1"}'} + headers: + Content-Length: ['160'] + Content-Type: [application/json] + Date: ['Thu, 20 Dec 2018 22:05:19 GMT'] + Expires: ['0'] + X-Request-Id: [xoxtnw7b3inm3mzrrrqtrsjqme] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer wcpukqnp3tr4pg9g8otsh1iufw] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: DELETE + uri: http://localhost:8065/api/v4/emoji/1b4i1w5j8p85irmfx1ddcmr11y + response: + body: {string: '{"status":"OK"}'} + headers: + Content-Length: ['15'] + Content-Type: [application/json] + Date: ['Thu, 20 Dec 2018 22:05:19 GMT'] + X-Request-Id: [bc5s5u4kap8jdraz9gmyqqw4mh] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer wcpukqnp3tr4pg9g8otsh1iufw] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/logout + response: + body: {string: '{"status":"OK"}'} + headers: + Content-Length: ['15'] + Content-Type: [application/json] + Date: ['Tue, 08 Jan 2019 20:29:38 GMT'] + Set-Cookie: [MMAUTHTOKEN=; Path=/; Max-Age=0; HttpOnly] + X-Request-Id: [f91ag7xknt8zt8h1xf7ngg5puc] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +version: 1 diff --git a/tests/cassettes/test_force_create_emoji.yaml b/tests/cassettes/test_force_create_emoji.yaml new file mode 100644 index 00000000..f83a523c --- /dev/null +++ b/tests/cassettes/test_force_create_emoji.yaml @@ -0,0 +1,229 @@ +interactions: +- request: + body: '{"login_id": "user-1@sample.mattermost.com", "password": "user-1", "token": + null}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Connection: [keep-alive] + Content-Length: ['81'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/login + response: + body: {string: '{"id":"jjcp4yj9gtr7bdfj43s7ukfh6w","create_at":1545253049270,"update_at":1545253049270,"delete_at":0,"username":"user-1","auth_data":"","auth_service":"","email":"user-1@sample.mattermost.com","email_verified":true,"nickname":"","first_name":"Victor","last_name":"Welch","position":"Design + Engineer","roles":"system_user","notify_props":{"channel":"true","comments":"never","desktop":"mention","desktop_sound":"true","email":"true","first_name":"false","mention_keys":",@","push":"mention","push_status":"away"},"last_password_update":1545253049270,"locale":"en","timezone":{"automaticTimezone":"","manualTimezone":"","useAutomaticTimezone":"true"}}'} + headers: + Content-Length: ['649'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 20:46:14 GMT'] + Set-Cookie: ['MMAUTHTOKEN=eksttk8k6ifpbpkou3uxm6gq1y; Path=/; Expires=Tue, 05 + Feb 2019 20:46:14 GMT; Max-Age=2592000; HttpOnly', 'MMUSERID=jjcp4yj9gtr7bdfj43s7ukfh6w; + Path=/; Expires=Tue, 05 Feb 2019 20:46:14 GMT; Max-Age=2592000'] + Token: [eksttk8k6ifpbpkou3uxm6gq1y] + X-Request-Id: [6hceqjsaspnzjjha6jd1gwk77h] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer eksttk8k6ifpbpkou3uxm6gq1y] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: GET + uri: http://localhost:8065/api/v4/emoji/name/emoji_1 + response: + body: {string: '{"id":"store.sql_emoji.get_by_name.app_error","message":"Unable + to get the emoji","detailed_error":"","request_id":"ugrfwfgc8prb3q53taq4k1r84y","status_code":404}'} + headers: + Content-Length: ['162'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 20:46:14 GMT'] + Expires: ['0'] + X-Request-Id: [ugrfwfgc8prb3q53taq4k1r84y] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 404, message: Not Found} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer eksttk8k6ifpbpkou3uxm6gq1y] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: GET + uri: http://localhost:8065/api/v4/emoji/name/emoji_1 + response: + body: {string: '{"id":"store.sql_emoji.get_by_name.app_error","message":"Unable + to get the emoji","detailed_error":"","request_id":"11isfztohbr4ij1shekr397t8o","status_code":404}'} + headers: + Content-Length: ['162'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 20:46:14 GMT'] + Expires: ['0'] + X-Request-Id: [11isfztohbr4ij1shekr397t8o] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 404, message: Not Found} +- request: + body: !!binary | + LS1hMTg5YjgyMzBmZjNkZjgxOGM5MjgyMTVmYzA3MmM4OA0KQ29udGVudC1EaXNwb3NpdGlvbjog + Zm9ybS1kYXRhOyBuYW1lPSJlbW9qaSINCg0KeyJuYW1lIjogImVtb2ppXzEiLCAiY3JlYXRvcl9p + ZCI6ICJqamNwNHlqOWd0cjdiZGZqNDNzN3VrZmg2dyJ9DQotLWExODliODIzMGZmM2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AAFYAK + QAWgAlABqABUACoAFYAKQAWgAlABqABUACoAFYAKQAWgAlABqABUACoAFYAKQAWgAlABqABUACoA + FYAKQAWgZtjaOv2dB3HxTJ7zzpP8uZuwdSaP+fn/a8Nb1ukJHML17W/zm1OngNYAFYAKQAWgAlAB + qABUVVXVpu9PAg9fbpqJaG8AAAAASUVORK5CYIINCi0tYTE4OWI4MjMwZmYzZGY4MThjOTI4MjE1 + ZmMwNzJjODgtLQ0K + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer eksttk8k6ifpbpkou3uxm6gq1y] + Connection: [keep-alive] + Content-Length: ['1152'] + Content-Type: [multipart/form-data; boundary=a189b8230ff3df818c928215fc072c88] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/emoji + response: + body: {string: '{"id":"uxzxgpp7r3bmtng9pe796ff8kw","create_at":1546807574923,"update_at":1546807574923,"delete_at":0,"creator_id":"jjcp4yj9gtr7bdfj43s7ukfh6w","name":"emoji_1"}'} + headers: + Content-Length: ['160'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 20:46:14 GMT'] + X-Request-Id: [d37oqdsh5tnatbby6xdzy9m4sa] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{"login_id": "user-1@sample.mattermost.com", "password": "user-1", "token": + null}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Connection: [keep-alive] + Content-Length: ['81'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/login + response: + body: {string: '{"id":"jjcp4yj9gtr7bdfj43s7ukfh6w","create_at":1545253049270,"update_at":1545253049270,"delete_at":0,"username":"user-1","auth_data":"","auth_service":"","email":"user-1@sample.mattermost.com","email_verified":true,"nickname":"","first_name":"Victor","last_name":"Welch","position":"Design + Engineer","roles":"system_user","notify_props":{"channel":"true","comments":"never","desktop":"mention","desktop_sound":"true","email":"true","first_name":"false","mention_keys":",@","push":"mention","push_status":"away"},"last_password_update":1545253049270,"locale":"en","timezone":{"automaticTimezone":"","manualTimezone":"","useAutomaticTimezone":"true"}}'} + headers: + Content-Length: ['649'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 20:46:15 GMT'] + Set-Cookie: ['MMAUTHTOKEN=8mprfgrmf3b1pyhik1rj4nssur; Path=/; Expires=Tue, 05 + Feb 2019 20:46:15 GMT; Max-Age=2592000; HttpOnly', 'MMUSERID=jjcp4yj9gtr7bdfj43s7ukfh6w; + Path=/; Expires=Tue, 05 Feb 2019 20:46:15 GMT; Max-Age=2592000'] + Token: [8mprfgrmf3b1pyhik1rj4nssur] + X-Request-Id: [nusmz7odfidzfmrix6bc3kbybw] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer 8mprfgrmf3b1pyhik1rj4nssur] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: GET + uri: http://localhost:8065/api/v4/emoji/name/emoji_1 + response: + body: {string: '{"id":"uxzxgpp7r3bmtng9pe796ff8kw","create_at":1546807574923,"update_at":1546807574923,"delete_at":0,"creator_id":"jjcp4yj9gtr7bdfj43s7ukfh6w","name":"emoji_1"}'} + headers: + Content-Length: ['160'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 20:46:15 GMT'] + Expires: ['0'] + X-Request-Id: [pfpouaaw6ibwzb1fmpm8judkre] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer 8mprfgrmf3b1pyhik1rj4nssur] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: DELETE + uri: http://localhost:8065/api/v4/emoji/uxzxgpp7r3bmtng9pe796ff8kw + response: + body: {string: '{"status":"OK"}'} + headers: + Content-Length: ['15'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 20:46:15 GMT'] + X-Request-Id: [s9oq1to487nkpgh9mkrax9pfpc] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer 8mprfgrmf3b1pyhik1rj4nssur] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/logout + response: + body: {string: '{"status":"OK"}'} + headers: + Content-Length: ['15'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 20:46:15 GMT'] + Set-Cookie: [MMAUTHTOKEN=; Path=/; Max-Age=0; HttpOnly] + X-Request-Id: [xh9rchbnf7nh5kga7pcs1t48th] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer 8mprfgrmf3b1pyhik1rj4nssur] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/logout + response: + body: {string: '{"status":"OK"}'} + headers: + Content-Length: ['15'] + Content-Type: [application/json] + Date: ['Tue, 08 Jan 2019 20:29:37 GMT'] + Set-Cookie: [MMAUTHTOKEN=; Path=/; Max-Age=0; HttpOnly] + X-Request-Id: [68848of4ppd9ux8oejd3kqu71w] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +version: 1 diff --git a/tests/cassettes/test_force_create_existing_emoji.yaml b/tests/cassettes/test_force_create_existing_emoji.yaml new file mode 100644 index 00000000..32c81be4 --- /dev/null +++ b/tests/cassettes/test_force_create_existing_emoji.yaml @@ -0,0 +1,316 @@ +interactions: +- request: + body: '{"login_id": "user-1@sample.mattermost.com", "password": "user-1", "token": + null}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Connection: [keep-alive] + Content-Length: ['81'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/login + response: + body: {string: '{"id":"jjcp4yj9gtr7bdfj43s7ukfh6w","create_at":1545253049270,"update_at":1545253049270,"delete_at":0,"username":"user-1","auth_data":"","auth_service":"","email":"user-1@sample.mattermost.com","email_verified":true,"nickname":"","first_name":"Victor","last_name":"Welch","position":"Design + Engineer","roles":"system_user","notify_props":{"channel":"true","comments":"never","desktop":"mention","desktop_sound":"true","email":"true","first_name":"false","mention_keys":",@","push":"mention","push_status":"away"},"last_password_update":1545253049270,"locale":"en","timezone":{"automaticTimezone":"","manualTimezone":"","useAutomaticTimezone":"true"}}'} + headers: + Content-Length: ['649'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 20:48:20 GMT'] + Set-Cookie: ['MMAUTHTOKEN=keba3yc19b89xfqqqefe9snprh; Path=/; Expires=Tue, 05 + Feb 2019 20:48:20 GMT; Max-Age=2592000; HttpOnly', 'MMUSERID=jjcp4yj9gtr7bdfj43s7ukfh6w; + Path=/; Expires=Tue, 05 Feb 2019 20:48:20 GMT; Max-Age=2592000'] + Token: [keba3yc19b89xfqqqefe9snprh] + X-Request-Id: [yxj5zg16rbdzjncpq63raprjww] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: !!binary | + LS1hZTkxMmIzNWM5ZTgwZjllNTBkZjFiYT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7++9/wH7cf46Po63nPizAIv7XMB6HgGO4+Xx/RGr27zbsQ/ft39s3tcB/tob + +A7vtqhbJoBjVjdoaoGngApABaACUAGoAFQAKgAVgApABaACUAGoAFQAKgAVgApABaACUAGoAFQA + KgAVgApABaACUAGoAFQAKgAVgApABaACUAGoAFQAKgAVgApABaACUAGoAFQAKgAVgApABSAAFYAK + QAWgAlABqABUACoAFYAKQAWgAlABqABUACoAFYAKQAWgAlABqABUACoAFYAKQAWgAlABqABUACoA + FYAKQAWgZtjaOv2dB3HxTJ7zzpP8uZuwdSaP+fn/a8Nb1ukJHML17W/zm1OngNYAFYAKQAWgAlAB + qABUVVXVpu9PAg9fbpqJaG8AAAAASUVORK5CYIINCi0tYWU5MTJiMzVjOWU4MGY5ZTUwZGYxYmEy + MDViOWVkOTMtLQ0K + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer keba3yc19b89xfqqqefe9snprh] + Connection: [keep-alive] + Content-Length: ['1152'] + Content-Type: [multipart/form-data; boundary=ae912b35c9e80f9e50df1ba205b9ed93] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/emoji + response: + body: {string: '{"id":"4p4uww1pipy838f65wm49a11go","create_at":1546807700887,"update_at":1546807700887,"delete_at":0,"creator_id":"jjcp4yj9gtr7bdfj43s7ukfh6w","name":"emoji_1"}'} + headers: + Content-Length: ['160'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 20:48:20 GMT'] + X-Request-Id: [rdw9tnzzwpd6pkseqfow9axezc] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer keba3yc19b89xfqqqefe9snprh] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/logout + response: + body: {string: '{"status":"OK"}'} + headers: + Content-Length: ['15'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 20:48:20 GMT'] + Set-Cookie: [MMAUTHTOKEN=; Path=/; Max-Age=0; HttpOnly] + X-Request-Id: [k7oeb8xz8bdy3gos3y35gtrxxr] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{"login_id": "user-1@sample.mattermost.com", "password": "user-1", "token": + null}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Connection: [keep-alive] + Content-Length: ['81'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/login + response: + body: {string: '{"id":"jjcp4yj9gtr7bdfj43s7ukfh6w","create_at":1545253049270,"update_at":1545253049270,"delete_at":0,"username":"user-1","auth_data":"","auth_service":"","email":"user-1@sample.mattermost.com","email_verified":true,"nickname":"","first_name":"Victor","last_name":"Welch","position":"Design + Engineer","roles":"system_user","notify_props":{"channel":"true","comments":"never","desktop":"mention","desktop_sound":"true","email":"true","first_name":"false","mention_keys":",@","push":"mention","push_status":"away"},"last_password_update":1545253049270,"locale":"en","timezone":{"automaticTimezone":"","manualTimezone":"","useAutomaticTimezone":"true"}}'} + headers: + Content-Length: ['649'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 20:48:21 GMT'] + Set-Cookie: ['MMAUTHTOKEN=zcs1uawg8idfug55d1xp8379pc; Path=/; Expires=Tue, 05 + Feb 2019 20:48:21 GMT; Max-Age=2592000; HttpOnly', 'MMUSERID=jjcp4yj9gtr7bdfj43s7ukfh6w; + Path=/; Expires=Tue, 05 Feb 2019 20:48:21 GMT; Max-Age=2592000'] + Token: [zcs1uawg8idfug55d1xp8379pc] + X-Request-Id: [fpi9n1hq73dnuemkuq7zs9hdwe] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer zcs1uawg8idfug55d1xp8379pc] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: GET + uri: http://localhost:8065/api/v4/emoji/name/emoji_1 + response: + body: {string: '{"id":"4p4uww1pipy838f65wm49a11go","create_at":1546807700887,"update_at":1546807700887,"delete_at":0,"creator_id":"jjcp4yj9gtr7bdfj43s7ukfh6w","name":"emoji_1"}'} + headers: + Content-Length: ['160'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 20:48:21 GMT'] + Expires: ['0'] + X-Request-Id: [j9zpa5pjw3rtdc3uwwfkgm6apa] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer zcs1uawg8idfug55d1xp8379pc] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: DELETE + uri: http://localhost:8065/api/v4/emoji/4p4uww1pipy838f65wm49a11go + response: + body: {string: '{"status":"OK"}'} + headers: + Content-Length: ['15'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 20:48:21 GMT'] + X-Request-Id: [6upyyfg7qt8cjgeec5c8ob76to] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: !!binary | + LS03NDM3YzMwOWY5ZTNmNjNjMGQzYzRlZTdiN2ZkYzA3OA0KQ29udGVudC1EaXNwb3NpdGlvbjog + Zm9ybS1kYXRhOyBuYW1lPSJlbW9qaSINCg0KeyJuYW1lIjogImVtb2ppXzEiLCAiY3JlYXRvcl9p + ZCI6ICJqamNwNHlqOWd0cjdiZGZqNDNzN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ABaACUAGoAFQAKgAVgApABaACUAGoAFQAKgAVgApABSAAFYAK + QAWgAlABqABUACoAFYAKQAWgAlABqABUACoAFYAKQAWgAlABqABUACoAFYAKQAWgAlABqABUACoA + FYAKQAWgZtjaOv2dB3HxTJ7zzpP8uZuwdSaP+fn/a8Nb1ukJHML17W/zm1OngNYAFYAKQAWgAlAB + qABUVVXVpu9PAg9fbpqJaG8AAAAASUVORK5CYIINCi0tNzQzN2MzMDlmOWUzZjYzYzBkM2M0ZWU3 + YjdmZGMwNzgtLQ0K + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer zcs1uawg8idfug55d1xp8379pc] + Connection: [keep-alive] + Content-Length: ['1152'] + Content-Type: [multipart/form-data; boundary=7437c309f9e3f63c0d3c4ee7b7fdc078] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/emoji + response: + body: {string: '{"id":"e9nr73347j83xc34517jhuoigy","create_at":1546807701083,"update_at":1546807701083,"delete_at":0,"creator_id":"jjcp4yj9gtr7bdfj43s7ukfh6w","name":"emoji_1"}'} + headers: + Content-Length: ['160'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 20:48:21 GMT'] + X-Request-Id: [rq9mrrgzqfyqtjojih75yoxssc] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{"login_id": "user-1@sample.mattermost.com", "password": "user-1", "token": + null}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Connection: [keep-alive] + Content-Length: ['81'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/login + response: + body: {string: '{"id":"jjcp4yj9gtr7bdfj43s7ukfh6w","create_at":1545253049270,"update_at":1545253049270,"delete_at":0,"username":"user-1","auth_data":"","auth_service":"","email":"user-1@sample.mattermost.com","email_verified":true,"nickname":"","first_name":"Victor","last_name":"Welch","position":"Design + Engineer","roles":"system_user","notify_props":{"channel":"true","comments":"never","desktop":"mention","desktop_sound":"true","email":"true","first_name":"false","mention_keys":",@","push":"mention","push_status":"away"},"last_password_update":1545253049270,"locale":"en","timezone":{"automaticTimezone":"","manualTimezone":"","useAutomaticTimezone":"true"}}'} + headers: + Content-Length: ['649'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 20:48:21 GMT'] + Set-Cookie: ['MMAUTHTOKEN=puxm9p5xyi8c8fifsfmhnzq79o; Path=/; Expires=Tue, 05 + Feb 2019 20:48:21 GMT; Max-Age=2592000; HttpOnly', 'MMUSERID=jjcp4yj9gtr7bdfj43s7ukfh6w; + Path=/; Expires=Tue, 05 Feb 2019 20:48:21 GMT; Max-Age=2592000'] + Token: [puxm9p5xyi8c8fifsfmhnzq79o] + X-Request-Id: [4xfbczc1b7f8mpjz3qufp113po] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer puxm9p5xyi8c8fifsfmhnzq79o] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: GET + uri: http://localhost:8065/api/v4/emoji/name/emoji_1 + response: + body: {string: '{"id":"e9nr73347j83xc34517jhuoigy","create_at":1546807701083,"update_at":1546807701083,"delete_at":0,"creator_id":"jjcp4yj9gtr7bdfj43s7ukfh6w","name":"emoji_1"}'} + headers: + Content-Length: ['160'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 20:48:21 GMT'] + Expires: ['0'] + X-Request-Id: [7gtkrdcr7pyhxb6peno5rgw18e] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer puxm9p5xyi8c8fifsfmhnzq79o] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: DELETE + uri: http://localhost:8065/api/v4/emoji/e9nr73347j83xc34517jhuoigy + response: + body: {string: '{"status":"OK"}'} + headers: + Content-Length: ['15'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 20:48:21 GMT'] + X-Request-Id: [wq47tapfdfysfdhwi1agybax6h] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer puxm9p5xyi8c8fifsfmhnzq79o] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/logout + response: + body: {string: '{"status":"OK"}'} + headers: + Content-Length: ['15'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 20:48:21 GMT'] + Set-Cookie: [MMAUTHTOKEN=; Path=/; Max-Age=0; HttpOnly] + X-Request-Id: [3f4uwt99u78ftpzspog15ki5qo] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer puxm9p5xyi8c8fifsfmhnzq79o] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/logout + response: + body: {string: '{"status":"OK"}'} + headers: + Content-Length: ['15'] + Content-Type: [application/json] + Date: ['Tue, 08 Jan 2019 20:29:37 GMT'] + Set-Cookie: [MMAUTHTOKEN=; Path=/; Max-Age=0; HttpOnly] + X-Request-Id: [p1uixhnbitgrfgf37kzns6ytor] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +version: 1 diff --git a/tests/cassettes/test_force_delete_absent_emoji.yaml b/tests/cassettes/test_force_delete_absent_emoji.yaml new file mode 100644 index 00000000..1a65ee8e --- /dev/null +++ b/tests/cassettes/test_force_delete_absent_emoji.yaml @@ -0,0 +1,73 @@ +interactions: +- request: + body: '{"login_id": "user-1@sample.mattermost.com", "password": "user-1", "token": + null}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Connection: [keep-alive] + Content-Length: ['81'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/login + response: + body: {string: '{"id":"jjcp4yj9gtr7bdfj43s7ukfh6w","create_at":1545253049270,"update_at":1545253049270,"delete_at":0,"username":"user-1","auth_data":"","auth_service":"","email":"user-1@sample.mattermost.com","email_verified":true,"nickname":"","first_name":"Victor","last_name":"Welch","position":"Design + Engineer","roles":"system_user","notify_props":{"channel":"true","comments":"never","desktop":"mention","desktop_sound":"true","email":"true","first_name":"false","mention_keys":",@","push":"mention","push_status":"away"},"last_password_update":1545253049270,"locale":"en","timezone":{"automaticTimezone":"","manualTimezone":"","useAutomaticTimezone":"true"}}'} + headers: + Content-Length: ['649'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 22:31:25 GMT'] + Set-Cookie: ['MMAUTHTOKEN=7fwngyky6bdquemqsbiwbwskjr; Path=/; Expires=Tue, 05 + Feb 2019 22:31:25 GMT; Max-Age=2592000; HttpOnly', 'MMUSERID=jjcp4yj9gtr7bdfj43s7ukfh6w; + Path=/; Expires=Tue, 05 Feb 2019 22:31:25 GMT; Max-Age=2592000'] + Token: [7fwngyky6bdquemqsbiwbwskjr] + X-Request-Id: [nryg98pchff59b348ja6p44cqe] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer 7fwngyky6bdquemqsbiwbwskjr] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: GET + uri: http://localhost:8065/api/v4/emoji/name/absent_emoji + response: + body: {string: '{"id":"store.sql_emoji.get_by_name.app_error","message":"Unable + to get the emoji","detailed_error":"","request_id":"9qowa4f8a7ru8dq3dpm8ec3hcr","status_code":404}'} + headers: + Content-Length: ['162'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 22:31:25 GMT'] + Expires: ['0'] + X-Request-Id: [9qowa4f8a7ru8dq3dpm8ec3hcr] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 404, message: Not Found} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer 7fwngyky6bdquemqsbiwbwskjr] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/logout + response: + body: {string: '{"status":"OK"}'} + headers: + Content-Length: ['15'] + Content-Type: [application/json] + Date: ['Tue, 08 Jan 2019 20:29:38 GMT'] + Set-Cookie: [MMAUTHTOKEN=; Path=/; Max-Age=0; HttpOnly] + X-Request-Id: [neai7iippj85jp1yntccmpjkdw] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +version: 1 diff --git a/tests/cassettes/test_force_delete_emoji.yaml b/tests/cassettes/test_force_delete_emoji.yaml new file mode 100644 index 00000000..b774a59b --- /dev/null +++ b/tests/cassettes/test_force_delete_emoji.yaml @@ -0,0 +1,183 @@ +interactions: +- request: + body: '{"login_id": "user-1@sample.mattermost.com", "password": "user-1", "token": + null}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Connection: [keep-alive] + Content-Length: ['81'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/login + response: + body: {string: '{"id":"jjcp4yj9gtr7bdfj43s7ukfh6w","create_at":1545253049270,"update_at":1545253049270,"delete_at":0,"username":"user-1","auth_data":"","auth_service":"","email":"user-1@sample.mattermost.com","email_verified":true,"nickname":"","first_name":"Victor","last_name":"Welch","position":"Design + Engineer","roles":"system_user","notify_props":{"channel":"true","comments":"never","desktop":"mention","desktop_sound":"true","email":"true","first_name":"false","mention_keys":",@","push":"mention","push_status":"away"},"last_password_update":1545253049270,"locale":"en","timezone":{"automaticTimezone":"","manualTimezone":"","useAutomaticTimezone":"true"}}'} + headers: + Content-Length: ['649'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 22:31:25 GMT'] + Set-Cookie: ['MMAUTHTOKEN=3f73qkq9rpbf3dcphk6nh79aaw; Path=/; Expires=Tue, 05 + Feb 2019 22:31:25 GMT; Max-Age=2592000; HttpOnly', 'MMUSERID=jjcp4yj9gtr7bdfj43s7ukfh6w; + Path=/; Expires=Tue, 05 Feb 2019 22:31:25 GMT; Max-Age=2592000'] + Token: [3f73qkq9rpbf3dcphk6nh79aaw] + X-Request-Id: [4847wweez3f43pfwrs9x3c6sjh] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: !!binary | + LS0wNmEwMTE2MmVkYmE1N2Q1NDdlNTViYTkzMDI1NzZkYg0KQ29udGVudC1EaXNwb3NpdGlvbjog + Zm9ybS1kYXRhOyBuYW1lPSJlbW9qaSINCg0KeyJuYW1lIjogImVtb2ppXzEiLCAiY3JlYXRvcl9p + ZCI6ICJqamNwNHlqOWd0cjdiZGZqNDNzN3VrZmg2dyJ9DQotLTA2YTAxMTYyZWRiYTU3ZDU0N2U1 + NWJhOTMwMjU3NmRiDQpDb250ZW50LURpc3Bvc2l0aW9uOiBmb3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QAWgAlABqABUACoA + FYAKQAWgZtjaOv2dB3HxTJ7zzpP8uZuwdSaP+fn/a8Nb1ukJHML17W/zm1OngNYAFYAKQAWgAlAB + qABUVVXVpu9PAg9fbpqJaG8AAAAASUVORK5CYIINCi0tMDZhMDExNjJlZGJhNTdkNTQ3ZTU1YmE5 + MzAyNTc2ZGItLQ0K + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer 3f73qkq9rpbf3dcphk6nh79aaw] + Connection: [keep-alive] + Content-Length: ['1152'] + Content-Type: [multipart/form-data; boundary=06a01162edba57d547e55ba9302576db] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/emoji + response: + body: {string: '{"id":"f5zko7u1jfy6m8oye9rsocyoah","create_at":1546813885443,"update_at":1546813885443,"delete_at":0,"creator_id":"jjcp4yj9gtr7bdfj43s7ukfh6w","name":"emoji_1"}'} + headers: + Content-Length: ['160'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 22:31:25 GMT'] + X-Request-Id: [dknmw9bio3rsbr74mwf68stj3o] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer 3f73qkq9rpbf3dcphk6nh79aaw] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/logout + response: + body: {string: '{"status":"OK"}'} + headers: + Content-Length: ['15'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 22:31:25 GMT'] + Set-Cookie: [MMAUTHTOKEN=; Path=/; Max-Age=0; HttpOnly] + X-Request-Id: [rten8pr6kjr73kj8kooeaupcjy] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{"login_id": "user-1@sample.mattermost.com", "password": "user-1", "token": + null}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Connection: [keep-alive] + Content-Length: ['81'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/login + response: + body: {string: '{"id":"jjcp4yj9gtr7bdfj43s7ukfh6w","create_at":1545253049270,"update_at":1545253049270,"delete_at":0,"username":"user-1","auth_data":"","auth_service":"","email":"user-1@sample.mattermost.com","email_verified":true,"nickname":"","first_name":"Victor","last_name":"Welch","position":"Design + Engineer","roles":"system_user","notify_props":{"channel":"true","comments":"never","desktop":"mention","desktop_sound":"true","email":"true","first_name":"false","mention_keys":",@","push":"mention","push_status":"away"},"last_password_update":1545253049270,"locale":"en","timezone":{"automaticTimezone":"","manualTimezone":"","useAutomaticTimezone":"true"}}'} + headers: + Content-Length: ['649'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 22:31:25 GMT'] + Set-Cookie: ['MMAUTHTOKEN=x985cj3k5t8dtxfuixp57o9ddh; Path=/; Expires=Tue, 05 + Feb 2019 22:31:25 GMT; Max-Age=2592000; HttpOnly', 'MMUSERID=jjcp4yj9gtr7bdfj43s7ukfh6w; + Path=/; Expires=Tue, 05 Feb 2019 22:31:25 GMT; Max-Age=2592000'] + Token: [x985cj3k5t8dtxfuixp57o9ddh] + X-Request-Id: [ysdeke9q1b8s9jwjc5q5dt1ite] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer x985cj3k5t8dtxfuixp57o9ddh] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: GET + uri: http://localhost:8065/api/v4/emoji/name/emoji_1 + response: + body: {string: '{"id":"f5zko7u1jfy6m8oye9rsocyoah","create_at":1546813885443,"update_at":1546813885443,"delete_at":0,"creator_id":"jjcp4yj9gtr7bdfj43s7ukfh6w","name":"emoji_1"}'} + headers: + Content-Length: ['160'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 22:31:25 GMT'] + Expires: ['0'] + X-Request-Id: [nbd6obecejd1ixyo5usuoj948c] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer x985cj3k5t8dtxfuixp57o9ddh] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: DELETE + uri: http://localhost:8065/api/v4/emoji/f5zko7u1jfy6m8oye9rsocyoah + response: + body: {string: '{"status":"OK"}'} + headers: + Content-Length: ['15'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 22:31:25 GMT'] + X-Request-Id: [1kho8e9b4j8cjkfskc33i4fueh] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer x985cj3k5t8dtxfuixp57o9ddh] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/logout + response: + body: {string: '{"status":"OK"}'} + headers: + Content-Length: ['15'] + Content-Type: [application/json] + Date: ['Tue, 08 Jan 2019 20:29:38 GMT'] + Set-Cookie: [MMAUTHTOKEN=; Path=/; Max-Age=0; HttpOnly] + X-Request-Id: [gh84rqs6xpds3yt8x6zq9zt5zr] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +version: 1 diff --git a/tests/cassettes/test_interactive_create_emoji.yaml b/tests/cassettes/test_interactive_create_emoji.yaml new file mode 100644 index 00000000..7b1be432 --- /dev/null +++ b/tests/cassettes/test_interactive_create_emoji.yaml @@ -0,0 +1,606 @@ +interactions: +- request: + body: '{"login_id": "user-1@sample.mattermost.com", "password": "user-1", "token": + null}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Connection: [keep-alive] + Content-Length: ['81'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/login + response: + body: {string: '{"id":"jjcp4yj9gtr7bdfj43s7ukfh6w","create_at":1545253049270,"update_at":1545253049270,"delete_at":0,"username":"user-1","auth_data":"","auth_service":"","email":"user-1@sample.mattermost.com","email_verified":true,"nickname":"","first_name":"Victor","last_name":"Welch","position":"Design + Engineer","roles":"system_user","notify_props":{"channel":"true","comments":"never","desktop":"mention","desktop_sound":"true","email":"true","first_name":"false","mention_keys":",@","push":"mention","push_status":"away"},"last_password_update":1545253049270,"locale":"en","timezone":{"automaticTimezone":"","manualTimezone":"","useAutomaticTimezone":"true"}}'} + headers: + Content-Length: ['649'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 22:00:02 GMT'] + Set-Cookie: ['MMAUTHTOKEN=qip6b99e1p8ndg5ep539ib4iew; Path=/; Expires=Tue, 05 + Feb 2019 22:00:02 GMT; Max-Age=2592000; HttpOnly', 'MMUSERID=jjcp4yj9gtr7bdfj43s7ukfh6w; + Path=/; Expires=Tue, 05 Feb 2019 22:00:02 GMT; Max-Age=2592000'] + Token: [qip6b99e1p8ndg5ep539ib4iew] + X-Request-Id: [pzhqk9wbmigxbye4nfjo1ahrcc] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: !!binary | + LS00N2UyYmI3NDNiNTFlNmU1NjYxNGRlMmQ4ZWI5MmIzZA0KQ29udGVudC1EaXNwb3NpdGlvbjog + Zm9ybS1kYXRh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Rhl46tuRQtQ+TGMKkAXssQ + /F1AP7kxTDoA72cIfi3max8RINXAZxmCvywRkAiQfmh3r8UmU75Tg3mj53oS50lgZo73XwWMS3Hd + ykTkooCx2GXebvqF7kQP2tA/5f1qP6IJU4GGDGv8mzxphwTgMCzNyjDe7wMu96g9EoAFbYFFGYK/ + CbtqnRKAR1TiloSp0d7Dz7N7EkAKeuCWiqXR5uJv/SMJ4H8YhMmm5TrTf9Dz9kkAp2EE7oc46oAb + A2ijBHAK7sb9+7xdwIBA2ikBNMMMTP5cl+CvAc4LqK0SQAFtgHkZJnuvA2cG1mYJIKEdsNQx8A1J + rxEiEkDSZa/PMNkLucpGyQugL7DTMfjbEwciAYTJEEylDNcDHDHk4ClZAdyKewKmZ4mnsnlJCmAK + bmf1jwLjI3sQSk4AMx2f+j349RpXAnBgkmPwPwa6RDoJ9loAxU5u7JpHZ0MybMSI18L2Jbv1NEQu + lMsFEoCQAIQEICQAIQEICUBIAEIIIYSInX8Ar5aPpbr7Ag8AAAAASUVORK5CYIINCi0tNDdlMmJi + NzQzYjUxZTZlNTY2MTRkZTJkOGViOTJiM2QtLQ0K + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer qip6b99e1p8ndg5ep539ib4iew] + Connection: [keep-alive] + Content-Length: ['2082'] + Content-Type: [multipart/form-data; boundary=47e2bb743b51e6e56614de2d8eb92b3d] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/emoji + response: + body: {string: '{"id":"gufih9i8g3rydkf9953tgq3d6h","create_at":1546812002198,"update_at":1546812002198,"delete_at":0,"creator_id":"jjcp4yj9gtr7bdfj43s7ukfh6w","name":"emoji_2"}'} + headers: + Content-Length: ['160'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 22:00:02 GMT'] + X-Request-Id: [gk6abot5otnr7mweyket4ke9sh] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code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+ headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer qip6b99e1p8ndg5ep539ib4iew] + Connection: [keep-alive] + Content-Length: ['2335'] + Content-Type: [multipart/form-data; boundary=30fb206326aebea10702397867033863] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/emoji + response: + body: {string: '{"id":"b1zfm14a53yafjh4s8xhhoua5e","create_at":1546812002218,"update_at":1546812002218,"delete_at":0,"creator_id":"jjcp4yj9gtr7bdfj43s7ukfh6w","name":"emoji_3"}'} + headers: + Content-Length: ['160'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 22:00:02 GMT'] + X-Request-Id: [kp9iaztsoj8wjyjuqcpaxrotny] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer qip6b99e1p8ndg5ep539ib4iew] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/logout + response: + body: {string: '{"status":"OK"}'} + headers: + Content-Length: ['15'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 22:00:02 GMT'] + Set-Cookie: [MMAUTHTOKEN=; Path=/; Max-Age=0; HttpOnly] + X-Request-Id: [tzxke9r4wjn4xcthraykiin8zo] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{"login_id": "user-1@sample.mattermost.com", "password": "user-1", "token": + null}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Connection: [keep-alive] + Content-Length: ['81'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/login + response: + body: {string: '{"id":"jjcp4yj9gtr7bdfj43s7ukfh6w","create_at":1545253049270,"update_at":1545253049270,"delete_at":0,"username":"user-1","auth_data":"","auth_service":"","email":"user-1@sample.mattermost.com","email_verified":true,"nickname":"","first_name":"Victor","last_name":"Welch","position":"Design + Engineer","roles":"system_user","notify_props":{"channel":"true","comments":"never","desktop":"mention","desktop_sound":"true","email":"true","first_name":"false","mention_keys":",@","push":"mention","push_status":"away"},"last_password_update":1545253049270,"locale":"en","timezone":{"automaticTimezone":"","manualTimezone":"","useAutomaticTimezone":"true"}}'} + headers: + Content-Length: ['649'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 22:00:02 GMT'] + Set-Cookie: ['MMAUTHTOKEN=kc3nnzyrepbq8px8d83pzqnqnh; Path=/; Expires=Tue, 05 + Feb 2019 22:00:02 GMT; Max-Age=2592000; HttpOnly', 'MMUSERID=jjcp4yj9gtr7bdfj43s7ukfh6w; + Path=/; Expires=Tue, 05 Feb 2019 22:00:02 GMT; Max-Age=2592000'] + Token: [kc3nnzyrepbq8px8d83pzqnqnh] + X-Request-Id: [8hfszmqcqtd7bnba8w75ri4exc] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer kc3nnzyrepbq8px8d83pzqnqnh] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: GET + uri: http://localhost:8065/api/v4/emoji/name/emoji_1 + response: + body: {string: '{"id":"store.sql_emoji.get_by_name.app_error","message":"Unable + to get the emoji","detailed_error":"","request_id":"t3hgpionw7gc5yuxurkxkifpao","status_code":404}'} + headers: + Content-Length: ['162'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 22:00:02 GMT'] + Expires: ['0'] + X-Request-Id: [t3hgpionw7gc5yuxurkxkifpao] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 404, message: Not Found} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer kc3nnzyrepbq8px8d83pzqnqnh] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: GET + uri: http://localhost:8065/api/v4/emoji/name/emoji_1 + response: + body: {string: '{"id":"store.sql_emoji.get_by_name.app_error","message":"Unable + to get the emoji","detailed_error":"","request_id":"gozjy5qnbjy8jk7e3jsuz6nihy","status_code":404}'} + headers: + Content-Length: ['162'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 22:00:02 GMT'] + Expires: ['0'] + X-Request-Id: [gozjy5qnbjy8jk7e3jsuz6nihy] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 404, message: Not Found} +- request: + body: !!binary | + LS00NzYxMjQwNjIzNjBjZjVmOGE1NjQzYjM2Y2E3MDFkZQ0KQ29udGVudC1EaXNwb3NpdGlvbjog + Zm9ybS1kYXRhOyBuYW1lPSJlbW9qaSINCg0KeyJuYW1lIjogImVtb2ppXzEiLCAiY3JlYXRvcl9p + ZCI6ICJqamNwNHlqOWd0cjdiZGZqNDNzN3VrZmg2dyJ9DQotLTQ3NjEyNDA2MjM2MGNmNWY4YTU2 + NDNiMzZjYTcwMWRlDQpDb250ZW50LURpc3Bvc2l0aW9uOiBmb3JtLWRhdGE7IG5hbWU9ImltYWdl + IjsgZmlsZW5hbWU9ImVtb2ppXzEucG5nIg0KDQqJUE5HDQoaCgAAAA1JSERSAAAAgAAAAIAIBgAA + AMM+YcsAAAAGYktHRAD/AP8A/6C9p5MAAAAJcEhZcwAALiMAAC4jAXilP3YAAAAHdElNRQfiDBQP + NjVZIC+LAAAC5ElEQVR42u3bTahmcxzA8c9wMRFJQ0KDiCaNxZRSymKiCAuFjbzkJcrkdTk1iykl + pshGyQpZsLGSTFI2k7KYkpXVyAZJkylkwuL5L1hMRo7bufd8v3XrLu4993nu73PO+Z/nPA/L7FTc + jUP44wRfzy3hH7G2sMGfg0fwJC5ViwFw+Rj6wzi7sS8HwA14BnfilMa9DABruAvP4rpGvBwA5+LR + cai/pNEuB8CVY+gP4axGuhwAN47D/B2d35cD4DTcMwa/q/EtB8B5eAx7cFFjWw6Aq/EUHsCZjWs5 + AHaP6/fbsGXC7f6Ko7ig0a+a0+Lp9LGnH8bHuH3C4R/FC7gMHzX2eR0BtuFxPIELJ972N3gFr+On + xj0vADvwNO7H1om3/SVewjv4rTHPC8DN4/x+y8Tnd/gUL+IDq1u6NRMAZ+Decf1+zcTb/h3vj8F/ + 1kjnB2Cv1Uu1U6+8f8GbOICvGuV8AeyYePg/4jW8im8b4fwvAw9MtJ2vx9ph+ziqNPwNAuAwDv6H + 3/8C9+GKcUl3rLFtLADGJdm/7RPcimvxNo43ro0L4OA4EpzMiv49q3fy7MaHjWhzAPintcDPY2F3 + ldXt3s8bzea84jji7++9/wH7cf46Po63nPizAIv7XMB6HgGO4+Xx/RGr27zbsQ/ft39s3tcB/tob + +A7vtqhbJoBjVjdoaoGngApABaACUAGoAFQAKgAVgApABaACUAGoAFQAKgAVgApABaACUAGoAFQA + KgAVgApABaACUAGoAFQAKgAVgApABaACUAGoAFQAKgAVgApABaACUAGoAFQAKgAVgApABSAAFYAK + QAWgAlABqABUACoAFYAKQAWgAlABqABUACoAFYAKQAWgAlABqABUACoAFYAKQAWgAlABqABUACoA + FYAKQAWgZtjaOv2dB3HxTJ7zzpP8uZuwdSaP+fn/a8Nb1ukJHML17W/zm1OngNYAFYAKQAWgAlAB + qABUVVXVpu9PAg9fbpqJaG8AAAAASUVORK5CYIINCi0tNDc2MTI0MDYyMzYwY2Y1ZjhhNTY0M2Iz + NmNhNzAxZGUtLQ0K + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer kc3nnzyrepbq8px8d83pzqnqnh] + Connection: [keep-alive] + Content-Length: ['1152'] + Content-Type: [multipart/form-data; boundary=476124062360cf5f8a5643b36ca701de] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/emoji + response: + body: {string: '{"id":"gzjfn94d47gdxrybsqnuc4q9uc","create_at":1546812002405,"update_at":1546812002405,"delete_at":0,"creator_id":"jjcp4yj9gtr7bdfj43s7ukfh6w","name":"emoji_1"}'} + headers: + Content-Length: ['160'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 22:00:02 GMT'] + X-Request-Id: [xm4wx96qttgqzx517c1hxqdxcw] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer kc3nnzyrepbq8px8d83pzqnqnh] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: GET + uri: http://localhost:8065/api/v4/emoji/name/emoji_2 + response: + body: {string: '{"id":"gufih9i8g3rydkf9953tgq3d6h","create_at":1546812002198,"update_at":1546812002198,"delete_at":0,"creator_id":"jjcp4yj9gtr7bdfj43s7ukfh6w","name":"emoji_2"}'} + headers: + Content-Length: ['160'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 22:00:02 GMT'] + Expires: ['0'] + X-Request-Id: [ke7nfa98r3nzxctif5tms7a1te] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer kc3nnzyrepbq8px8d83pzqnqnh] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: DELETE + uri: http://localhost:8065/api/v4/emoji/gufih9i8g3rydkf9953tgq3d6h + response: + body: {string: '{"status":"OK"}'} + headers: + Content-Length: ['15'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 22:00:02 GMT'] + X-Request-Id: [snru7f47ffy5uno47w411a9dsh] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: !!binary | + LS0yOTA0ZWMwMGMxZjUyZjM1ZGJkOGRmYTc3M2VlZGY4Zg0KQ29udGVudC1EaXNwb3NpdGlvbjog + Zm9ybS1kYXRhOyBuYW1lPSJlbW9qaSINCg0KeyJuYW1lIjogImVtb2ppXzIiLCAiY3JlYXRvcl9p + ZCI6ICJqamNwNHlqOWd0cjdiZGZqNDNzN3VrZmg2dyJ9DQotLTI5MDRlYzAwYzFmNTJmMzVkYmQ4 + ZGZhNzczZWVkZjhmDQpDb250ZW50LURpc3Bvc2l0aW9uOiBmb3JtLWRhdGE7IG5hbWU9ImltYWdl + IjsgZmlsZW5hbWU9ImVtb2ppXzIucG5nIg0KDQqJUE5HDQoaCgAAAA1JSERSAAAAgAAAAIAIBgAA + AMM+YcsAAAAGYktHRAD/AP8A/6C9p5MAAAAJcEhZcwAALiMAAC4jAXilP3YAAAAHdElNRQfiDBQP + Ox83NZgQAAAGhklEQVR42u2dW4hWVRTHfzNOlrdmynQyryUpWphRRkyalWRmQVqQRhJaZhfsoQeV + KIqQKJG0J3sorciEwtAKU1KMEi81laaWF9IyQ5MsxxzLyrEe9hn6nEY7e59v5uy9v/8PFt/DHIaz + 1/qffTv7rFVGXPQEBgADE7sQqATOLvhtCxwB6pPfPcA3iX0FfJL8TQRAV+AuYAGwF/i7CHYcqAXm + AMOBcrnZLzoDjwIbgRNFCvrp7EdgHnC1XJ8fZcB1wCLgWCsE/VS2ARgPVCgkrUMbYAqwM8egN2ff + ARMSYYoWYhSw1bPAN7WNwAiFqrgMAj7wPPBNbX6yyhAZOAd4GWgILPiNthcYqTC6cUMRl3F52gng + cYUzPRXA7FZazrWmvQW0D2V5lRfnAou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NXaJIIRnDEvW7C7BX4d7tXLhASOwO8WrquARkaWY9RbS5QAWnnI7Jjm1 + S/A3Y84DiECZhKlP6BL8L/Tkh8003Eu/f4oHhR6FG2XA7AzBX0tOqVxFdiqw+2SrqX2kpV64tAPe + zRD8VZRIle8YqQLWZAj+cuxy/QqP6AZ8mSH4i9HefrD0BXZnCP5LmGJXIkAGY1e9u6nNkgvDZTim + Qodr8KfLheEyBvd9/ePAZLkwXO7DfWv3GHCHXBguMzJ0+Ucwr4NFgJRhl46tuRQtQ+TGMKkAXssQ + /F1AP7kxTDoA72cIfi3max8RINXAZxmCvywRkAiQfmh3r8UmU75Tg3mj53oS50lgZo73XwWMS3Hd + ykTkooCx2GXebvqF7kQP2tA/5f1qP6IJU4GGDGv8mzxphwTgMCzNyjDe7wMu96g9EoAFbYFFGYK/ + CbtqnRKAR1TiloSp0d7Dz7N7EkAKeuCWiqXR5uJv/SMJ4H8YhMmm5TrTf9Dz9kkAp2EE7oc46oAb + A2ijBHAK7sb9+7xdwIBA2ikBNMMMTP5cl+CvAc4LqK0SQAFtgHkZJnuvA2cG1mYJIKEdsNQx8A1J + rxEiEkDSZa/PMNkLucpGyQugL7DTMfjbEwciAYTJEEylDNcDHDHk4ClZAdyKewKmZ4mnsnlJCmAK + bmf1jwLjI3sQSk4AMx2f+j349RpXAnBgkmPwPwa6RDoJ9loAxU5u7JpHZ0MybMSI18L2Jbv1NEQu + lMsFEoCQAIQEICQAIQEICUBIAEIIIYSInX8Ar5aPpbr7Ag8AAAAASUVORK5CYIINCi0tMjkwNGVj + MDBjMWY1MmYzNWRiZDhkZmE3NzNlZWRmOGYtLQ0K + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer kc3nnzyrepbq8px8d83pzqnqnh] + Connection: [keep-alive] + Content-Length: ['2082'] + Content-Type: [multipart/form-data; boundary=2904ec00c1f52f35dbd8dfa773eedf8f] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/emoji + response: + body: {string: '{"id":"zk3asgw5ibdxdpmsoj4efqqyay","create_at":1546812002458,"update_at":1546812002458,"delete_at":0,"creator_id":"jjcp4yj9gtr7bdfj43s7ukfh6w","name":"emoji_2"}'} + headers: + Content-Length: ['160'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 22:00:02 GMT'] + X-Request-Id: [4ddoyohr9ffpufcjhe3r5px1pw] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer kc3nnzyrepbq8px8d83pzqnqnh] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: GET + uri: http://localhost:8065/api/v4/emoji/name/emoji_3 + response: + body: {string: '{"id":"b1zfm14a53yafjh4s8xhhoua5e","create_at":1546812002218,"update_at":1546812002218,"delete_at":0,"creator_id":"jjcp4yj9gtr7bdfj43s7ukfh6w","name":"emoji_3"}'} + headers: + Content-Length: ['160'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 22:00:02 GMT'] + Expires: ['0'] + X-Request-Id: [nr3hxopon3f3tdfd1tt5at3o5h] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{"login_id": "user-1@sample.mattermost.com", "password": "user-1", "token": + null}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Connection: [keep-alive] + Content-Length: ['81'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/login + response: + body: {string: '{"id":"jjcp4yj9gtr7bdfj43s7ukfh6w","create_at":1545253049270,"update_at":1545253049270,"delete_at":0,"username":"user-1","auth_data":"","auth_service":"","email":"user-1@sample.mattermost.com","email_verified":true,"nickname":"","first_name":"Victor","last_name":"Welch","position":"Design + Engineer","roles":"system_user","notify_props":{"channel":"true","comments":"never","desktop":"mention","desktop_sound":"true","email":"true","first_name":"false","mention_keys":",@","push":"mention","push_status":"away"},"last_password_update":1545253049270,"locale":"en","timezone":{"automaticTimezone":"","manualTimezone":"","useAutomaticTimezone":"true"}}'} + headers: + Content-Length: ['649'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 22:00:02 GMT'] + Set-Cookie: ['MMAUTHTOKEN=xn9msgzuotfsmpjfdzdep8tyhr; Path=/; Expires=Tue, 05 + Feb 2019 22:00:02 GMT; Max-Age=2592000; HttpOnly', 'MMUSERID=jjcp4yj9gtr7bdfj43s7ukfh6w; + Path=/; Expires=Tue, 05 Feb 2019 22:00:02 GMT; Max-Age=2592000'] + Token: [xn9msgzuotfsmpjfdzdep8tyhr] + X-Request-Id: [5mi6cgpsbtbybxy6i1r6a194za] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer xn9msgzuotfsmpjfdzdep8tyhr] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: GET + uri: http://localhost:8065/api/v4/emoji/name/emoji_1 + response: + body: {string: '{"id":"gzjfn94d47gdxrybsqnuc4q9uc","create_at":1546812002405,"update_at":1546812002405,"delete_at":0,"creator_id":"jjcp4yj9gtr7bdfj43s7ukfh6w","name":"emoji_1"}'} + headers: + Content-Length: ['160'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 22:00:02 GMT'] + Expires: ['0'] + X-Request-Id: [95ioxferd7nsteurxt6e9gjush] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer xn9msgzuotfsmpjfdzdep8tyhr] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: DELETE + uri: http://localhost:8065/api/v4/emoji/gzjfn94d47gdxrybsqnuc4q9uc + response: + body: {string: '{"status":"OK"}'} + headers: + Content-Length: ['15'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 22:00:02 GMT'] + X-Request-Id: [ir58pj6mj78cbqfwonxuxinr6r] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer xn9msgzuotfsmpjfdzdep8tyhr] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: GET + uri: http://localhost:8065/api/v4/emoji/name/emoji_2 + response: + body: {string: '{"id":"zk3asgw5ibdxdpmsoj4efqqyay","create_at":1546812002458,"update_at":1546812002458,"delete_at":0,"creator_id":"jjcp4yj9gtr7bdfj43s7ukfh6w","name":"emoji_2"}'} + headers: + Content-Length: ['160'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 22:00:02 GMT'] + Expires: ['0'] + X-Request-Id: [z1xj49d5kfr6dkqufod6e6cqbr] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer xn9msgzuotfsmpjfdzdep8tyhr] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: DELETE + uri: http://localhost:8065/api/v4/emoji/zk3asgw5ibdxdpmsoj4efqqyay + response: + body: {string: '{"status":"OK"}'} + headers: + Content-Length: ['15'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 22:00:02 GMT'] + X-Request-Id: [i7qgw6xf8bfhidkxy65kxaskyw] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer xn9msgzuotfsmpjfdzdep8tyhr] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: GET + uri: http://localhost:8065/api/v4/emoji/name/emoji_3 + response: + body: {string: '{"id":"b1zfm14a53yafjh4s8xhhoua5e","create_at":1546812002218,"update_at":1546812002218,"delete_at":0,"creator_id":"jjcp4yj9gtr7bdfj43s7ukfh6w","name":"emoji_3"}'} + headers: + Content-Length: ['160'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 22:00:02 GMT'] + Expires: ['0'] + X-Request-Id: [b4or7z9ug7bp8ggxwwmxpoz97a] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer xn9msgzuotfsmpjfdzdep8tyhr] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: DELETE + uri: http://localhost:8065/api/v4/emoji/b1zfm14a53yafjh4s8xhhoua5e + response: + body: {string: '{"status":"OK"}'} + headers: + Content-Length: ['15'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 22:00:02 GMT'] + X-Request-Id: [5fa45oz3tpy5fmw5x48xi4496a] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer xn9msgzuotfsmpjfdzdep8tyhr] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/logout + response: + body: {string: '{"status":"OK"}'} + headers: + Content-Length: ['15'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 22:00:02 GMT'] + Set-Cookie: [MMAUTHTOKEN=; Path=/; Max-Age=0; HttpOnly] + X-Request-Id: [jsgze7pjj7rutejmxj8yyuedhe] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer xn9msgzuotfsmpjfdzdep8tyhr] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/logout + response: + body: {string: '{"status":"OK"}'} + headers: + Content-Length: ['15'] + Content-Type: [application/json] + Date: ['Tue, 08 Jan 2019 20:29:38 GMT'] + Set-Cookie: [MMAUTHTOKEN=; Path=/; Max-Age=0; HttpOnly] + X-Request-Id: [ytx44kdp3jygtgwkb7wgoijgne] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +version: 1 diff --git a/tests/cassettes/test_interactive_delete_emoji.yaml b/tests/cassettes/test_interactive_delete_emoji.yaml new file mode 100644 index 00000000..ab520c42 --- /dev/null +++ b/tests/cassettes/test_interactive_delete_emoji.yaml @@ -0,0 +1,354 @@ +interactions: +- request: + body: '{"login_id": "user-1@sample.mattermost.com", "password": "user-1", "token": + null}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Connection: [keep-alive] + Content-Length: ['81'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/login + response: + body: {string: '{"id":"jjcp4yj9gtr7bdfj43s7ukfh6w","create_at":1545253049270,"update_at":1545253049270,"delete_at":0,"username":"user-1","auth_data":"","auth_service":"","email":"user-1@sample.mattermost.com","email_verified":true,"nickname":"","first_name":"Victor","last_name":"Welch","position":"Design + Engineer","roles":"system_user","notify_props":{"channel":"true","comments":"never","desktop":"mention","desktop_sound":"true","email":"true","first_name":"false","mention_keys":",@","push":"mention","push_status":"away"},"last_password_update":1545253049270,"locale":"en","timezone":{"automaticTimezone":"","manualTimezone":"","useAutomaticTimezone":"true"}}'} + headers: + Content-Length: ['649'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 22:58:24 GMT'] + Set-Cookie: ['MMAUTHTOKEN=n8r7eeijifrmtmcny9i1jz4d1w; Path=/; Expires=Tue, 05 + Feb 2019 22:58:24 GMT; Max-Age=2592000; HttpOnly', 'MMUSERID=jjcp4yj9gtr7bdfj43s7ukfh6w; + Path=/; Expires=Tue, 05 Feb 2019 22:58:24 GMT; Max-Age=2592000'] + Token: [n8r7eeijifrmtmcny9i1jz4d1w] + X-Request-Id: [8sa6ybk61irmp8osriwog1zmsh] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: !!binary | + LS1iZWQ3YTA2MmU2Zjg1MGI2NzI5NjM1NzM1Nzc2ZGE1ZQ0KQ29udGVudC1EaXNwb3NpdGlvbjog + Zm9ybS1kYXRhOyBuYW1lPSJlbW9qaSINCg0KeyJuYW1lIjogImVtb2ppXzEiLCAiY3JlYXRvcl9p + ZCI6ICJqamNwNHlqOWd0cjdiZGZqNDNzN3VrZmg2dyJ9DQotLWJlZDdhMDYyZTZmODUwYjY3Mjk2 + MzU3MzU3NzZkYTVlDQpDb250ZW50LURpc3Bvc2l0aW9uOiBmb3JtLWRhdGE7IG5hbWU9ImltYWdl + IjsgZmlsZW5hbWU9ImVtb2ppXzEucG5nIg0KDQqJUE5HDQoaCgAAAA1JSERSAAAAgAAAAIAIBgAA + AMM+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bpqJaG8AAAAASUVORK5CYIINCi0tYmVkN2EwNjJlNmY4NTBiNjcyOTYzNTcz + NTc3NmRhNWUtLQ0K + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer n8r7eeijifrmtmcny9i1jz4d1w] + Connection: [keep-alive] + Content-Length: ['1152'] + Content-Type: [multipart/form-data; boundary=bed7a062e6f850b6729635735776da5e] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/emoji + response: + body: {string: '{"id":"cegnazh4wpb73fmjwa4u8tns8a","create_at":1546815504507,"update_at":1546815504507,"delete_at":0,"creator_id":"jjcp4yj9gtr7bdfj43s7ukfh6w","name":"emoji_1"}'} + headers: + Content-Length: ['160'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 22:58:24 GMT'] + X-Request-Id: [ywq6oiqyujremji39pwte3fhkw] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: !!binary | + LS0wYTljZDU4NmZiYTc3NDhiYjU2MzM1ZWY5MTI1ODEyOQ0KQ29udGVudC1EaXNwb3NpdGlvbjog + Zm9ybS1kYXRhOyBuYW1lPSJlbW9qaSINCg0KeyJuYW1lIjogImVtb2ppXzIiLCAiY3JlYXRvcl9p + ZCI6ICJqamNwNHlqOWd0cjdiZGZqNDNzN3VrZmg2dyJ9DQotLTBhOWNkNTg2ZmJhNzc0OGJiNTYz + MzVlZjkxMjU4MTI5DQpDb250ZW50LURpc3Bvc2l0aW9uOiBmb3JtLWRhdGE7IG5hbWU9ImltYWdl + IjsgZmlsZW5hbWU9ImVtb2ppXzIucG5nIg0KDQqJUE5HDQoaCgAAAA1JSERSAAAAgAAAAIAIBgAA + AMM+YcsAAAAGYktHRAD/AP8A/6C9p5MAAAAJcEhZcwAALiMAAC4jAXilP3YAAAAHdElNRQfiDBQP + Ox83NZgQAAAGhklEQVR42u2dW4hWVRTHfzNOlrdm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3sQSk4AMx2f+j349RpXAnBgkmPwPwa6RDoJ9loAxU5u7JpHZ0MybMSI18L2Jbv1NEQu + lMsFEoCQAIQEICQAIQEICUBIAEIIIYSInX8Ar5aPpbr7Ag8AAAAASUVORK5CYIINCi0tMGE5Y2Q1 + ODZmYmE3NzQ4YmI1NjMzNWVmOTEyNTgxMjktLQ0K + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer n8r7eeijifrmtmcny9i1jz4d1w] + Connection: [keep-alive] + Content-Length: ['2082'] + Content-Type: [multipart/form-data; boundary=0a9cd586fba7748bb56335ef91258129] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/emoji + response: + body: {string: '{"id":"fe57ujpd5pyzupr4sw1gub48tr","create_at":1546815504526,"update_at":1546815504526,"delete_at":0,"creator_id":"jjcp4yj9gtr7bdfj43s7ukfh6w","name":"emoji_2"}'} + headers: + Content-Length: ['160'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 22:58:24 GMT'] + X-Request-Id: [eytmnsq17ffdidi4ubgkh6dusy] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer n8r7eeijifrmtmcny9i1jz4d1w] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/logout + response: + body: {string: '{"status":"OK"}'} + headers: + Content-Length: ['15'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 22:58:24 GMT'] + Set-Cookie: [MMAUTHTOKEN=; Path=/; Max-Age=0; HttpOnly] + X-Request-Id: [ypmciowgzjbnfpbh3ratxa1inw] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{"login_id": "user-1@sample.mattermost.com", "password": "user-1", "token": + null}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Connection: [keep-alive] + Content-Length: ['81'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/login + response: + body: {string: '{"id":"jjcp4yj9gtr7bdfj43s7ukfh6w","create_at":1545253049270,"update_at":1545253049270,"delete_at":0,"username":"user-1","auth_data":"","auth_service":"","email":"user-1@sample.mattermost.com","email_verified":true,"nickname":"","first_name":"Victor","last_name":"Welch","position":"Design + Engineer","roles":"system_user","notify_props":{"channel":"true","comments":"never","desktop":"mention","desktop_sound":"true","email":"true","first_name":"false","mention_keys":",@","push":"mention","push_status":"away"},"last_password_update":1545253049270,"locale":"en","timezone":{"automaticTimezone":"","manualTimezone":"","useAutomaticTimezone":"true"}}'} + headers: + Content-Length: ['649'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 22:58:24 GMT'] + Set-Cookie: ['MMAUTHTOKEN=zmnbhdme3i8o7mqfi94pjkkaao; Path=/; Expires=Tue, 05 + Feb 2019 22:58:24 GMT; Max-Age=2592000; HttpOnly', 'MMUSERID=jjcp4yj9gtr7bdfj43s7ukfh6w; + Path=/; Expires=Tue, 05 Feb 2019 22:58:24 GMT; Max-Age=2592000'] + Token: [zmnbhdme3i8o7mqfi94pjkkaao] + X-Request-Id: [sapboe9n3brafekxsx6j9jgzia] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer zmnbhdme3i8o7mqfi94pjkkaao] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: GET + uri: http://localhost:8065/api/v4/emoji/name/emoji_1 + response: + body: {string: '{"id":"cegnazh4wpb73fmjwa4u8tns8a","create_at":1546815504507,"update_at":1546815504507,"delete_at":0,"creator_id":"jjcp4yj9gtr7bdfj43s7ukfh6w","name":"emoji_1"}'} + headers: + Content-Length: ['160'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 22:58:24 GMT'] + Expires: ['0'] + X-Request-Id: [wr18dd77mjnw3ym3xwqycdrwdr] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer zmnbhdme3i8o7mqfi94pjkkaao] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: DELETE + uri: http://localhost:8065/api/v4/emoji/cegnazh4wpb73fmjwa4u8tns8a + response: + body: {string: '{"status":"OK"}'} + headers: + Content-Length: ['15'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 22:58:24 GMT'] + X-Request-Id: [nzjc9apop7yndd1izd9z6uuqyw] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer zmnbhdme3i8o7mqfi94pjkkaao] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: GET + uri: http://localhost:8065/api/v4/emoji/name/emoji_2 + response: + body: {string: '{"id":"fe57ujpd5pyzupr4sw1gub48tr","create_at":1546815504526,"update_at":1546815504526,"delete_at":0,"creator_id":"jjcp4yj9gtr7bdfj43s7ukfh6w","name":"emoji_2"}'} + headers: + Content-Length: ['160'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 22:58:24 GMT'] + Expires: ['0'] + X-Request-Id: [qk6jkwxp9ff9inampxpcgk4nco] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{"login_id": "user-1@sample.mattermost.com", "password": "user-1", "token": + null}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Connection: [keep-alive] + Content-Length: ['81'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/login + response: + body: {string: '{"id":"jjcp4yj9gtr7bdfj43s7ukfh6w","create_at":1545253049270,"update_at":1545253049270,"delete_at":0,"username":"user-1","auth_data":"","auth_service":"","email":"user-1@sample.mattermost.com","email_verified":true,"nickname":"","first_name":"Victor","last_name":"Welch","position":"Design + Engineer","roles":"system_user","notify_props":{"channel":"true","comments":"never","desktop":"mention","desktop_sound":"true","email":"true","first_name":"false","mention_keys":",@","push":"mention","push_status":"away"},"last_password_update":1545253049270,"locale":"en","timezone":{"automaticTimezone":"","manualTimezone":"","useAutomaticTimezone":"true"}}'} + headers: + Content-Length: ['649'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 22:58:24 GMT'] + Set-Cookie: ['MMAUTHTOKEN=wnqrgorwh3dq3kp787771jx59e; Path=/; Expires=Tue, 05 + Feb 2019 22:58:24 GMT; Max-Age=2592000; HttpOnly', 'MMUSERID=jjcp4yj9gtr7bdfj43s7ukfh6w; + Path=/; Expires=Tue, 05 Feb 2019 22:58:24 GMT; Max-Age=2592000'] + Token: [wnqrgorwh3dq3kp787771jx59e] + X-Request-Id: [hemhuekum3dj3dfgpppeuztq7a] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer wnqrgorwh3dq3kp787771jx59e] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: GET + uri: http://localhost:8065/api/v4/emoji/name/emoji_2 + response: + body: {string: '{"id":"fe57ujpd5pyzupr4sw1gub48tr","create_at":1546815504526,"update_at":1546815504526,"delete_at":0,"creator_id":"jjcp4yj9gtr7bdfj43s7ukfh6w","name":"emoji_2"}'} + headers: + Content-Length: ['160'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 22:58:24 GMT'] + Expires: ['0'] + X-Request-Id: [ug3jr7ofpibf7qoncued8zshbe] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer wnqrgorwh3dq3kp787771jx59e] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: DELETE + uri: http://localhost:8065/api/v4/emoji/fe57ujpd5pyzupr4sw1gub48tr + response: + body: {string: '{"status":"OK"}'} + headers: + Content-Length: ['15'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 22:58:24 GMT'] + X-Request-Id: [ajaf6oh6bb8t7y8rp7em5r53ra] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer wnqrgorwh3dq3kp787771jx59e] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/logout + response: + body: {string: '{"status":"OK"}'} + headers: + Content-Length: ['15'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 22:58:24 GMT'] + Set-Cookie: [MMAUTHTOKEN=; Path=/; Max-Age=0; HttpOnly] + X-Request-Id: [n1bpmaasybnwdbffu48mdjpc5r] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer wnqrgorwh3dq3kp787771jx59e] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/logout + response: + body: {string: '{"status":"OK"}'} + headers: + Content-Length: ['15'] + Content-Type: [application/json] + Date: ['Tue, 08 Jan 2019 20:29:38 GMT'] + Set-Cookie: [MMAUTHTOKEN=; Path=/; Max-Age=0; HttpOnly] + X-Request-Id: [pyg6atsgmbd85jjgp6ngr5zegy] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +version: 1 diff --git a/tests/cassettes/test_no_clobber_create_emoji.yaml b/tests/cassettes/test_no_clobber_create_emoji.yaml new file mode 100644 index 00000000..b84668a1 --- /dev/null +++ b/tests/cassettes/test_no_clobber_create_emoji.yaml @@ -0,0 +1,229 @@ +interactions: +- request: + body: '{"login_id": "user-1@sample.mattermost.com", "password": "user-1", "token": + null}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Connection: [keep-alive] + Content-Length: ['81'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/login + response: + body: {string: '{"id":"jjcp4yj9gtr7bdfj43s7ukfh6w","create_at":1545253049270,"update_at":1545253049270,"delete_at":0,"username":"user-1","auth_data":"","auth_service":"","email":"user-1@sample.mattermost.com","email_verified":true,"nickname":"","first_name":"Victor","last_name":"Welch","position":"Design + Engineer","roles":"system_user","notify_props":{"channel":"true","comments":"never","desktop":"mention","desktop_sound":"true","email":"true","first_name":"false","mention_keys":",@","push":"mention","push_status":"away"},"last_password_update":1545253049270,"locale":"en","timezone":{"automaticTimezone":"","manualTimezone":"","useAutomaticTimezone":"true"}}'} + headers: + Content-Length: ['649'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 20:54:51 GMT'] + Set-Cookie: ['MMAUTHTOKEN=xd8ajwyx37yhxqxe6rha755qxe; Path=/; Expires=Tue, 05 + Feb 2019 20:54:51 GMT; Max-Age=2592000; HttpOnly', 'MMUSERID=jjcp4yj9gtr7bdfj43s7ukfh6w; + Path=/; Expires=Tue, 05 Feb 2019 20:54:51 GMT; Max-Age=2592000'] + Token: [xd8ajwyx37yhxqxe6rha755qxe] + X-Request-Id: [fniuinoemtdzpf4u6p4tejxysw] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer xd8ajwyx37yhxqxe6rha755qxe] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: GET + uri: http://localhost:8065/api/v4/emoji/name/emoji_1 + response: + body: {string: '{"id":"store.sql_emoji.get_by_name.app_error","message":"Unable + to get the emoji","detailed_error":"","request_id":"7nb1neghgjr65bmqfa38bdxaxr","status_code":404}'} + headers: + Content-Length: ['162'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 20:54:52 GMT'] + Expires: ['0'] + X-Request-Id: [7nb1neghgjr65bmqfa38bdxaxr] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 404, message: Not Found} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer xd8ajwyx37yhxqxe6rha755qxe] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: GET + uri: http://localhost:8065/api/v4/emoji/name/emoji_1 + response: + body: {string: '{"id":"store.sql_emoji.get_by_name.app_error","message":"Unable + to get the emoji","detailed_error":"","request_id":"ju6ihqooxpdftnoauzfrj3ensr","status_code":404}'} + headers: + Content-Length: ['162'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 20:54:52 GMT'] + Expires: ['0'] + X-Request-Id: [ju6ihqooxpdftnoauzfrj3ensr] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 404, message: Not Found} +- request: + body: !!binary | + LS03MjczMTZkZjFkY2JmMGMwYzY5NDE3NTZjYjg0NGYyNg0KQ29udGVudC1EaXNwb3NpdGlvbjog + Zm9ybS1kYXRhOyBuYW1lPSJlbW9qaSINCg0KeyJuYW1lIjogImVtb2ppXzEiLCAiY3JlYXRvcl9p + ZCI6ICJqamNwNHlqOWd0cjdiZGZqNDNzN3VrZmg2dyJ9DQotLTcyNzMxNmRmMWRjYmYwYzBjNjk0 + MTc1NmNiODQ0ZjI2DQpDb250ZW50LURpc3Bvc2l0aW9uOiBmb3JtLWRhdGE7IG5hbWU9ImltYWdl + IjsgZmlsZW5hbWU9ImVtb2ppXzEucG5nIg0KDQqJUE5HDQoaCgAAAA1JSERSAAAAgAAAAIAIBgAA + AMM+YcsAAAAGYktHRAD/AP8A/6C9p5MAAAAJcEhZcwAALiMAAC4jAXilP3YAAAAHdElNRQfiDBQP + NjVZIC+LAAAC5ElEQVR42u3bTahmcxzA8c9wMRFJQ0KDiCaNxZRSymKiCAuFjbzkJcrkdTk1iykl + pshGyQpZsLGSTFI2k7KYkpXVyAZJkylkwuL5L1hMRo7bufd8v3XrLu4993nu73PO+Z/nPA/L7FTc + jUP44wRfzy3hH7G2sMGfg0fwJC5ViwFw+Rj6wzi7sS8HwA14BnfilMa9DABruAvP4rpGvBwA5+LR + cai/pNEuB8CVY+gP4axGuhwAN47D/B2d35cD4DTcMwa/q/EtB8B5eAx7cFFjWw6Aq/EUHsCZjWs5 + AHaP6/fbsGXC7f6Ko7ig0a+a0+Lp9LGnH8bHuH3C4R/FC7gMHzX2eR0BtuFxPIELJ972N3gFr+On + xj0vADvwNO7H1om3/SVewjv4rTHPC8DN4/x+y8Tnd/gUL+IDq1u6NRMAZ+Decf1+zcTb/h3vj8F/ + 1kjnB2Cv1Uu1U6+8f8GbOICvGuV8AeyYePg/4jW8im8b4fwvAw9MtJ2vx9ph+ziqNPwNAuAwDv6H + 3/8C9+GKcUl3rLFtLADGJdm/7RPcimvxNo43ro0L4OA4EpzMiv49q3fy7MaHjWhzAPintcDPY2F3 + ldXt3s8bzea84jji7++9/wH7cf46Po63nPizAIv7XMB6HgGO4+Xx/RGr27zbsQ/ft39s3tcB/tob + +A7vtqhbJoBjVjdoaoGngApABaACUAGoAFQAKgAVgApABaACUAGoAFQAKgAVgApABaACUAGoAFQA + KgAVgApABaACUAGoAFQAKgAVgApABaACUAGoAFQAKgAVgApABaACUAGoAFQAKgAVgApABSAAFYAK + QAWgAlABqABUACoAFYAKQAWgAlABqABUACoAFYAKQAWgAlABqABUACoAFYAKQAWgAlABqABUACoA + FYAKQAWgZtjaOv2dB3HxTJ7zzpP8uZuwdSaP+fn/a8Nb1ukJHML17W/zm1OngNYAFYAKQAWgAlAB + qABUVVXVpu9PAg9fbpqJaG8AAAAASUVORK5CYIINCi0tNzI3MzE2ZGYxZGNiZjBjMGM2OTQxNzU2 + Y2I4NDRmMjYtLQ0K + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer xd8ajwyx37yhxqxe6rha755qxe] + Connection: [keep-alive] + Content-Length: ['1152'] + Content-Type: [multipart/form-data; boundary=727316df1dcbf0c0c6941756cb844f26] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/emoji + response: + body: {string: '{"id":"nt555zz13pf9zj5p93ataj4pjy","create_at":1546808092044,"update_at":1546808092044,"delete_at":0,"creator_id":"jjcp4yj9gtr7bdfj43s7ukfh6w","name":"emoji_1"}'} + headers: + Content-Length: ['160'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 20:54:52 GMT'] + X-Request-Id: [4giz5dtqwfrpjmqsczk9ak64ww] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{"login_id": "user-1@sample.mattermost.com", "password": "user-1", "token": + null}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Connection: [keep-alive] + Content-Length: ['81'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/login + response: + body: {string: '{"id":"jjcp4yj9gtr7bdfj43s7ukfh6w","create_at":1545253049270,"update_at":1545253049270,"delete_at":0,"username":"user-1","auth_data":"","auth_service":"","email":"user-1@sample.mattermost.com","email_verified":true,"nickname":"","first_name":"Victor","last_name":"Welch","position":"Design + Engineer","roles":"system_user","notify_props":{"channel":"true","comments":"never","desktop":"mention","desktop_sound":"true","email":"true","first_name":"false","mention_keys":",@","push":"mention","push_status":"away"},"last_password_update":1545253049270,"locale":"en","timezone":{"automaticTimezone":"","manualTimezone":"","useAutomaticTimezone":"true"}}'} + headers: + Content-Length: ['649'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 20:54:52 GMT'] + Set-Cookie: ['MMAUTHTOKEN=43fwnt5ydtr3jn3z5koj7ptjao; Path=/; Expires=Tue, 05 + Feb 2019 20:54:52 GMT; Max-Age=2592000; HttpOnly', 'MMUSERID=jjcp4yj9gtr7bdfj43s7ukfh6w; + Path=/; Expires=Tue, 05 Feb 2019 20:54:52 GMT; Max-Age=2592000'] + Token: [43fwnt5ydtr3jn3z5koj7ptjao] + X-Request-Id: [jj1ud94bctn9udix8gq1agq7wy] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer 43fwnt5ydtr3jn3z5koj7ptjao] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: GET + uri: http://localhost:8065/api/v4/emoji/name/emoji_1 + response: + body: {string: '{"id":"nt555zz13pf9zj5p93ataj4pjy","create_at":1546808092044,"update_at":1546808092044,"delete_at":0,"creator_id":"jjcp4yj9gtr7bdfj43s7ukfh6w","name":"emoji_1"}'} + headers: + Content-Length: ['160'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 20:54:52 GMT'] + Expires: ['0'] + X-Request-Id: [g71joa7sytyi8epa451xwjipya] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer 43fwnt5ydtr3jn3z5koj7ptjao] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: DELETE + uri: http://localhost:8065/api/v4/emoji/nt555zz13pf9zj5p93ataj4pjy + response: + body: {string: '{"status":"OK"}'} + headers: + Content-Length: ['15'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 20:54:52 GMT'] + X-Request-Id: [x9itnqkho3ncpywdo76yiute3o] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer 43fwnt5ydtr3jn3z5koj7ptjao] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/logout + response: + body: {string: '{"status":"OK"}'} + headers: + Content-Length: ['15'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 20:54:52 GMT'] + Set-Cookie: [MMAUTHTOKEN=; Path=/; Max-Age=0; HttpOnly] + X-Request-Id: [mkk1o5cyrfbgjbtxbbz7bnckoh] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer 43fwnt5ydtr3jn3z5koj7ptjao] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/logout + response: + body: {string: '{"status":"OK"}'} + headers: + Content-Length: ['15'] + Content-Type: [application/json] + Date: ['Tue, 08 Jan 2019 20:29:37 GMT'] + Set-Cookie: [MMAUTHTOKEN=; Path=/; Max-Age=0; HttpOnly] + X-Request-Id: [yhn3cwd5btghbj4yykyzz6ycrc] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +version: 1 diff --git a/tests/cassettes/test_no_clobber_create_existing_emoji.yaml b/tests/cassettes/test_no_clobber_create_existing_emoji.yaml new file mode 100644 index 00000000..7bb499c6 --- /dev/null +++ b/tests/cassettes/test_no_clobber_create_existing_emoji.yaml @@ -0,0 +1,253 @@ +interactions: +- request: + body: '{"login_id": "user-1@sample.mattermost.com", "password": "user-1", "token": + null}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Connection: [keep-alive] + Content-Length: ['81'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/login + response: + body: {string: '{"id":"jjcp4yj9gtr7bdfj43s7ukfh6w","create_at":1545253049270,"update_at":1545253049270,"delete_at":0,"username":"user-1","auth_data":"","auth_service":"","email":"user-1@sample.mattermost.com","email_verified":true,"nickname":"","first_name":"Victor","last_name":"Welch","position":"Design + Engineer","roles":"system_user","notify_props":{"channel":"true","comments":"never","desktop":"mention","desktop_sound":"true","email":"true","first_name":"false","mention_keys":",@","push":"mention","push_status":"away"},"last_password_update":1545253049270,"locale":"en","timezone":{"automaticTimezone":"","manualTimezone":"","useAutomaticTimezone":"true"}}'} + headers: + Content-Length: ['649'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 20:58:32 GMT'] + Set-Cookie: ['MMAUTHTOKEN=enqtw76dn3bsijheahx6nzafio; Path=/; Expires=Tue, 05 + Feb 2019 20:58:32 GMT; Max-Age=2592000; HttpOnly', 'MMUSERID=jjcp4yj9gtr7bdfj43s7ukfh6w; + Path=/; Expires=Tue, 05 Feb 2019 20:58:32 GMT; Max-Age=2592000'] + Token: [enqtw76dn3bsijheahx6nzafio] + X-Request-Id: [1n8su4hxh7dm7n9m3963dg9nco] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: !!binary | + LS1jZjA0Y2RiMmIwZTA2MmE0MzdjZWQyZTdlYWQ4MGJiZQ0KQ29udGVudC1EaXNwb3NpdGlvbjog + Zm9ybS1kYXRhOyBuYW1lPSJlbW9qaSINCg0KeyJuYW1lIjogImVtb2ppXzEiLCAiY3JlYXRvcl9p + ZCI6ICJqamNwNHlqOWd0cjdiZGZqNDNzN3VrZmg2dyJ9DQotLWNmMDRjZGIyYjBlMDYyYTQzN2Nl + ZDJlN2VhZDgwYmJlDQpDb250ZW50LURpc3Bvc2l0aW9uOiBmb3JtLWRhdGE7IG5hbWU9ImltYWdl + IjsgZmlsZW5hbWU9ImVtb2ppXzEucG5nIg0KDQqJUE5HDQoaCgAAAA1JSERSAAAAgAAAAIAIBgAA + AMM+YcsAAAAGYktHRAD/AP8A/6C9p5MAAAAJcEhZcwAALiMAAC4jAXilP3YAAAAHdElNRQfiDBQP + NjVZIC+LAAAC5ElEQVR42u3bTahmcxzA8c9wMRFJQ0KDiCaNxZRSymKiCAuFjbzkJcrkdTk1iykl + pshGyQpZsLGSTFI2k7KYkpXVyAZJkylkwuL5L1hMRo7bufd8v3XrLu4993nu73PO+Z/nPA/L7FTc + jUP44wRfzy3hH7G2sMGfg0fwJC5ViwFw+Rj6wzi7sS8HwA14BnfilMa9DABruAvP4rpGvBwA5+LR + cai/pNEuB8CVY+gP4axGuhwAN47D/B2d35cD4DTcMwa/q/EtB8B5eAx7cFFjWw6Aq/EUHsCZjWs5 + AHaP6/fbsGXC7f6Ko7ig0a+a0+Lp9LGnH8bHuH3C4R/FC7gMHzX2eR0BtuFxPIELJ972N3gFr+On + xj0vADvwNO7H1om3/SVewjv4rTHPC8DN4/x+y8Tnd/gUL+IDq1u6NRMAZ+Decf1+zcTb/h3vj8F/ + 1kjnB2Cv1Uu1U6+8f8GbOICvGuV8AeyYePg/4jW8im8b4fwvAw9MtJ2vx9ph+ziqNPwNAuAwDv6H + 3/8C9+GKcUl3rLFtLADGJdm/7RPcimvxNo43ro0L4OA4EpzMiv49q3fy7MaHjWhzAPintcDPY2F3 + ldXt3s8bzea84jji7++9/wH7cf46Po63nPizAIv7XMB6HgGO4+Xx/RGr27zbsQ/ft39s3tcB/tob + +A7vtqhbJoBjVjdoaoGngApABaACUAGoAFQAKgAVgApABaACUAGoAFQAKgAVgApABaACUAGoAFQA + KgAVgApABaACUAGoAFQAKgAVgApABaACUAGoAFQAKgAVgApABaACUAGoAFQAKgAVgApABSAAFYAK + QAWgAlABqABUACoAFYAKQAWgAlABqABUACoAFYAKQAWgAlABqABUACoAFYAKQAWgAlABqABUACoA + FYAKQAWgZtjaOv2dB3HxTJ7zzpP8uZuwdSaP+fn/a8Nb1ukJHML17W/zm1OngNYAFYAKQAWgAlAB + qABUVVXVpu9PAg9fbpqJaG8AAAAASUVORK5CYIINCi0tY2YwNGNkYjJiMGUwNjJhNDM3Y2VkMmU3 + ZWFkODBiYmUtLQ0K + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer enqtw76dn3bsijheahx6nzafio] + Connection: [keep-alive] + Content-Length: ['1152'] + Content-Type: [multipart/form-data; boundary=cf04cdb2b0e062a437ced2e7ead80bbe] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/emoji + response: + body: {string: '{"id":"5fgwek6rxfrebjjejc3xoynurw","create_at":1546808312205,"update_at":1546808312205,"delete_at":0,"creator_id":"jjcp4yj9gtr7bdfj43s7ukfh6w","name":"emoji_1"}'} + headers: + Content-Length: ['160'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 20:58:32 GMT'] + X-Request-Id: [niqektzqtjd8xc4fttbus6o5uc] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer enqtw76dn3bsijheahx6nzafio] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/logout + response: + body: {string: '{"status":"OK"}'} + headers: + Content-Length: ['15'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 20:58:32 GMT'] + Set-Cookie: [MMAUTHTOKEN=; Path=/; Max-Age=0; HttpOnly] + X-Request-Id: [o94x37s4o3gpmfxrchc8q9yqee] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{"login_id": "user-1@sample.mattermost.com", "password": "user-1", "token": + null}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Connection: [keep-alive] + Content-Length: ['81'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/login + response: + body: {string: '{"id":"jjcp4yj9gtr7bdfj43s7ukfh6w","create_at":1545253049270,"update_at":1545253049270,"delete_at":0,"username":"user-1","auth_data":"","auth_service":"","email":"user-1@sample.mattermost.com","email_verified":true,"nickname":"","first_name":"Victor","last_name":"Welch","position":"Design + Engineer","roles":"system_user","notify_props":{"channel":"true","comments":"never","desktop":"mention","desktop_sound":"true","email":"true","first_name":"false","mention_keys":",@","push":"mention","push_status":"away"},"last_password_update":1545253049270,"locale":"en","timezone":{"automaticTimezone":"","manualTimezone":"","useAutomaticTimezone":"true"}}'} + headers: + Content-Length: ['649'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 20:58:32 GMT'] + Set-Cookie: ['MMAUTHTOKEN=9ujqu9ktg38p5knfmt83ruojmh; Path=/; Expires=Tue, 05 + Feb 2019 20:58:32 GMT; Max-Age=2592000; HttpOnly', 'MMUSERID=jjcp4yj9gtr7bdfj43s7ukfh6w; + Path=/; Expires=Tue, 05 Feb 2019 20:58:32 GMT; Max-Age=2592000'] + Token: [9ujqu9ktg38p5knfmt83ruojmh] + X-Request-Id: [65os1jw3niyfudckcdbsn3cjxc] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer 9ujqu9ktg38p5knfmt83ruojmh] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: GET + uri: http://localhost:8065/api/v4/emoji/name/emoji_1 + response: + body: {string: '{"id":"5fgwek6rxfrebjjejc3xoynurw","create_at":1546808312205,"update_at":1546808312205,"delete_at":0,"creator_id":"jjcp4yj9gtr7bdfj43s7ukfh6w","name":"emoji_1"}'} + headers: + Content-Length: ['160'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 20:58:32 GMT'] + Expires: ['0'] + X-Request-Id: [8sxns3gdfj8xbkxbq4nozr4ych] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{"login_id": "user-1@sample.mattermost.com", "password": "user-1", "token": + null}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Connection: [keep-alive] + Content-Length: ['81'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/login + response: + body: {string: '{"id":"jjcp4yj9gtr7bdfj43s7ukfh6w","create_at":1545253049270,"update_at":1545253049270,"delete_at":0,"username":"user-1","auth_data":"","auth_service":"","email":"user-1@sample.mattermost.com","email_verified":true,"nickname":"","first_name":"Victor","last_name":"Welch","position":"Design + Engineer","roles":"system_user","notify_props":{"channel":"true","comments":"never","desktop":"mention","desktop_sound":"true","email":"true","first_name":"false","mention_keys":",@","push":"mention","push_status":"away"},"last_password_update":1545253049270,"locale":"en","timezone":{"automaticTimezone":"","manualTimezone":"","useAutomaticTimezone":"true"}}'} + headers: + Content-Length: ['649'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 20:58:32 GMT'] + Set-Cookie: ['MMAUTHTOKEN=ppkzib9k8bdyidp39iaz7znx9e; Path=/; Expires=Tue, 05 + Feb 2019 20:58:32 GMT; Max-Age=2592000; HttpOnly', 'MMUSERID=jjcp4yj9gtr7bdfj43s7ukfh6w; + Path=/; Expires=Tue, 05 Feb 2019 20:58:32 GMT; Max-Age=2592000'] + Token: [ppkzib9k8bdyidp39iaz7znx9e] + X-Request-Id: [3irdegrtutgetycg74drp8b6ka] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer ppkzib9k8bdyidp39iaz7znx9e] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: GET + uri: http://localhost:8065/api/v4/emoji/name/emoji_1 + response: + body: {string: '{"id":"5fgwek6rxfrebjjejc3xoynurw","create_at":1546808312205,"update_at":1546808312205,"delete_at":0,"creator_id":"jjcp4yj9gtr7bdfj43s7ukfh6w","name":"emoji_1"}'} + headers: + Content-Length: ['160'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 20:58:32 GMT'] + Expires: ['0'] + X-Request-Id: [dhrox88umink5q1rmetc6bcybh] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer ppkzib9k8bdyidp39iaz7znx9e] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: DELETE + uri: http://localhost:8065/api/v4/emoji/5fgwek6rxfrebjjejc3xoynurw + response: + body: {string: '{"status":"OK"}'} + headers: + Content-Length: ['15'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 20:58:32 GMT'] + X-Request-Id: [dmdh6jxajfrxd8kwrzpifr11sa] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer ppkzib9k8bdyidp39iaz7znx9e] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/logout + response: + body: {string: '{"status":"OK"}'} + headers: + Content-Length: ['15'] + Content-Type: [application/json] + Date: ['Sun, 06 Jan 2019 20:58:32 GMT'] + Set-Cookie: [MMAUTHTOKEN=; Path=/; Max-Age=0; HttpOnly] + X-Request-Id: [f7g3smbjniys3j9g6sftbcd8da] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +- request: + body: '{}' + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer ppkzib9k8bdyidp39iaz7znx9e] + Connection: [keep-alive] + Content-Length: ['2'] + Content-Type: [application/json] + User-Agent: [python-requests/2.21.0] + method: POST + uri: http://localhost:8065/api/v4/users/logout + response: + body: {string: '{"status":"OK"}'} + headers: + Content-Length: ['15'] + Content-Type: [application/json] + Date: ['Tue, 08 Jan 2019 20:29:37 GMT'] + Set-Cookie: [MMAUTHTOKEN=; Path=/; Max-Age=0; HttpOnly] + X-Request-Id: [eazmiba54idsdbrpn84bk4giea] + X-Version-Id: [5.6.0.5.6.1-rc2.ae8afd41bd6d75bc83c09cef963454ae.false] + status: {code: 200, message: OK} +version: 1 diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 00000000..73f472d0 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,7 @@ +import pytest +from click.testing import CliRunner + + +@pytest.fixture +def cli_runner(): + return CliRunner(mix_stderr=False) diff --git a/tests/emojis/emoji_1.png b/tests/emojis/emoji_1.png new file mode 100644 index 00000000..0fa0da45 Binary files /dev/null and b/tests/emojis/emoji_1.png differ diff --git a/tests/emojis/emoji_2.png b/tests/emojis/emoji_2.png new file mode 100644 index 00000000..727ace85 Binary files /dev/null and b/tests/emojis/emoji_2.png differ diff --git a/tests/emojis/emoji_3.png b/tests/emojis/emoji_3.png new file mode 100644 index 00000000..ba199679 Binary files /dev/null and b/tests/emojis/emoji_3.png differ diff --git a/tests/emojis/parentheses (spaced).png b/tests/emojis/parentheses (spaced).png new file mode 100644 index 00000000..3cf89022 Binary files /dev/null and b/tests/emojis/parentheses (spaced).png differ diff --git a/tests/scripts/.env.test b/tests/scripts/.env.test new file mode 100644 index 00000000..335300e3 --- /dev/null +++ b/tests/scripts/.env.test @@ -0,0 +1,3 @@ +export MM_URL='http://127.0.0.1:8065/api/v4' +export MM_LOGIN_ID="${1:-user-10}" +export MM_PASSWORD="${1:-user-10}" diff --git a/tests/scripts/setup.sh b/tests/scripts/setup.sh new file mode 100755 index 00000000..22236862 --- /dev/null +++ b/tests/scripts/setup.sh @@ -0,0 +1,56 @@ +#!/usr/bin/env bash +set -euo pipefail +IFS=$'\n\t' + +PORT='8065' +API="http://127.0.0.1:${PORT}/api/v4" +CONTAINER="mattermost-mmemoji" + +if ! docker info >/dev/null 2>&1; then + echo 'Docker needs to installed and running!' + exit 1 +fi + +echo "Creating test instance..." +docker run --detach \ + --name "${CONTAINER}" \ + --publish "${PORT}:8065" \ + --add-host dockerhost:127.0.0.1 \ + mattermost/mattermost-preview + +echo "Waiting for instance to be ready..." +until curl -fs "${API}/system/ping" >/dev/null; do sleep 1; done + +echo "Loading sample data..." +docker exec "${CONTAINER}" mattermost sampledata >/dev/null + +echo 'Enabling Custom Emoji...' +# The `config` subcommand was added in 5.6 +docker exec "${CONTAINER}" mattermost config \ + set ServiceSettings.EnableCustomEmoji true \ + --config=mattermost/config/config_docker.json >/dev/null + +printf 'Your environment is ready! +The following users should have been created: + +Username Email Password +----------------- ------------------------------ -------- +sysadmin sysadmin@sample.mattermost.com sysadmin +user-1 user-1@sample.mattermost.com user-1 +samuel.tucker user-2@sample.mattermost.com user-2 +rebecca.simpson user-3@sample.mattermost.com user-3 +louise.mccoy user-4@sample.mattermost.com user-4 +gloria.allen user-5@sample.mattermost.com user-5 +adam.torres user-6@sample.mattermost.com user-6 +jesse.welch user-7@sample.mattermost.com user-7 +brandon.ford user-8@sample.mattermost.com user-8 +denise.washington user-9@sample.mattermost.com user-9 +chris.jonese user-10@sample.mattermost.com user-10 +sandra.stone user-11@sample.mattermost.com user-11 +elizabeth.gardner user-12@sample.mattermost.com user-12 +kenneth.simmons user-13@sample.mattermost.com user-13 +nancy.sanders user-14@sample.mattermost.com user-14 + +' + +exit 0 diff --git a/tests/test_cli.py b/tests/test_cli.py new file mode 100644 index 00000000..777b2684 --- /dev/null +++ b/tests/test_cli.py @@ -0,0 +1,17 @@ +from click.testing import CliRunner + +from mmemoji.cli import cli +from mmemoji.version import VERSION + + +def test_help(): + runner = CliRunner() + result = runner.invoke(cli, ["--help"]) + assert result.exit_code == 0 + + +def test_version(): + runner = CliRunner() + result = runner.invoke(cli, ["--version"]) + assert result.exit_code == 0 + assert result.output == "mmemoji {}\n".format(VERSION) diff --git a/tests/test_commands_create.py b/tests/test_commands_create.py new file mode 100644 index 00000000..2e0cc847 --- /dev/null +++ b/tests/test_commands_create.py @@ -0,0 +1,165 @@ +import json + +import pytest +from click.testing import CliRunner + +from mmemoji.cli import cli + +from .utils import ( + EMOJIS, + create_emojis, + delete_emojis, + find_dict_in_list, + user_env, +) + + +def test_help(): + runner = CliRunner() + result = runner.invoke(cli, ["create", "--help"]) + assert result.exit_code == 0 + + +@pytest.mark.vcr() +def test_create_emoji(cli_runner): + # Setup + emoji_name = "emoji_1" + emoji_path = EMOJIS[emoji_name] + user = "user-1" + # Test + with user_env(user): + result = cli_runner.invoke(cli, ["create", emoji_path, "-o", "json"]) + emoji_list = json.loads(result.stdout) + emoji = find_dict_in_list(emoji_list, "name", emoji_name) + assert result.exit_code == 0 + assert len(emoji_list) == 1 + assert emoji["name"] == emoji_name + # Teardown + delete_emojis([emoji_name], user) + + +@pytest.mark.vcr() +def test_create_exiting_emoji(cli_runner): + # Setup + emoji_name = "emoji_1" + emoji_path = EMOJIS[emoji_name] + user = "user-1" + create_emojis([emoji_name], user) + # Test + with user_env(user): + result = cli_runner.invoke(cli, ["create", emoji_path, "-o", "json"]) + assert result.exit_code == 1 + error = result.stderr.split("\n")[-2] + assert error == 'Error: Emoji "{}" exists'.format(emoji_name) + # Teardown + delete_emojis([emoji_name], user) + + +@pytest.mark.vcr() +def test_force_create_emoji(cli_runner): + # Setup + emoji_name = "emoji_1" + emoji_path = EMOJIS[emoji_name] + user = "user-1" + # Test + with user_env(user): + result = cli_runner.invoke( + cli, ["create", "--force", emoji_path, "-o", "json"] + ) + emoji_list = json.loads(result.stdout) + emoji = find_dict_in_list(emoji_list, "name", emoji_name) + assert result.exit_code == 0 + assert len(emoji_list) == 1 + assert emoji["name"] == emoji_name + # Teardown + delete_emojis([emoji_name], user) + + +@pytest.mark.vcr() +def test_force_create_existing_emoji(cli_runner): + # Setup + emoji_name = "emoji_1" + emoji_path = EMOJIS[emoji_name] + user = "user-1" + create_emojis([emoji_name], user) + # Test + with user_env(user): + result = cli_runner.invoke( + cli, ["create", "--force", emoji_path, "-o", "json"] + ) + emoji_list = json.loads(result.stdout) + emoji = find_dict_in_list(emoji_list, "name", emoji_name) + assert result.exit_code == 0 + assert len(emoji_list) == 1 + assert emoji["name"] == emoji_name + # Teardown + delete_emojis([emoji_name], user) + + +@pytest.mark.vcr() +def test_no_clobber_create_emoji(cli_runner): + # Setup + emoji_name = "emoji_1" + emoji_path = EMOJIS[emoji_name] + user = "user-1" + # Test + with user_env(user): + result = cli_runner.invoke( + cli, ["create", "--no-clobber", emoji_path, "-o", "json"] + ) + emoji_list = json.loads(result.stdout) + emoji = find_dict_in_list(emoji_list, "name", emoji_name) + assert result.exit_code == 0 + assert len(emoji_list) == 1 + assert emoji["name"] == emoji_name + # Teardown + delete_emojis([emoji_name], user) + + +@pytest.mark.vcr() +def test_no_clobber_create_existing_emoji(cli_runner): + # Setup + emoji_name = "emoji_1" + emoji_path = EMOJIS[emoji_name] + user = "user-1" + create_emojis([emoji_name], user) + # Test + with user_env(user): + result = cli_runner.invoke( + cli, ["create", "--no-clobber", emoji_path, "-o", "json"] + ) + assert result.exit_code == 0 + assert result.stdout == "" + # Teardown + delete_emojis([emoji_name], user) + + +@pytest.mark.vcr() +def test_interactive_create_emoji(cli_runner): + # Setup + # 1st will not exist and will be created + # 2nd will exist and will be overwritten + # 3rd will exist and will not be overwritten + user = "user-1" + emoji_names = ["emoji_1", "emoji_2", "emoji_3"] + emoji_paths = [] + for name in emoji_names: + emoji_paths.append(EMOJIS[name]) + create_emojis(emoji_names[1:], user) + # Test + with user_env(user): + result = cli_runner.invoke( + cli, + ["create", "--interactive", "-o", "json"] + emoji_paths, + input="yes\nno\n", + ) + assert result.exit_code == 0 + # Output contains the invocation input as well + emoji_list = json.loads(result.stdout.split("\n")[-2]) + emoji1 = find_dict_in_list(emoji_list, "name", emoji_names[0]) + emoji2 = find_dict_in_list(emoji_list, "name", emoji_names[1]) + assert len(emoji_list) == 2 + assert emoji1["name"] == emoji_names[0] + assert emoji2["name"] == emoji_names[1] + # Teardown + delete_emojis(emoji_names, user) diff --git a/tests/test_commands_delete.py b/tests/test_commands_delete.py new file mode 100644 index 00000000..40b18b80 --- /dev/null +++ b/tests/test_commands_delete.py @@ -0,0 +1,110 @@ +import json + +import pytest +from click.testing import CliRunner + +from mmemoji.cli import cli + +from .utils import ( + EMOJIS, + create_emojis, + delete_emojis, + find_dict_in_list, + user_env, +) + + +def test_help(): + runner = CliRunner() + result = runner.invoke(cli, ["delete", "--help"]) + assert result.exit_code == 0 + + +@pytest.mark.vcr() +def test_delete_emoji(cli_runner): + # Setup + emoji_name = "emoji_1" + user = "user-1" + create_emojis([emoji_name], user) + # Test + with user_env(user): + result = cli_runner.invoke(cli, ["delete", emoji_name, "-o", "json"]) + emoji_list = json.loads(result.stdout) + emoji = find_dict_in_list(emoji_list, "name", emoji_name) + assert result.exit_code == 0 + assert len(emoji_list) == 1 + assert emoji["name"] == emoji_name + + +@pytest.mark.vcr() +def test_delete_absent_emoji(cli_runner): + # Setup + emoji_name = "absent_emoji" + user = "user-1" + # Test + with user_env(user): + result = cli_runner.invoke(cli, ["delete", emoji_name, "-o", "json"]) + assert result.exit_code == 1 + assert result.stdout == "" + error = result.stderr.split("\n")[-2] + assert error == 'Error: Emoji "{}" does not exist'.format(emoji_name) + + +@pytest.mark.vcr() +def test_force_delete_emoji(cli_runner): + # Setup + emoji_name = "emoji_1" + user = "user-1" + create_emojis([emoji_name], user) + # Test + with user_env(user): + result = cli_runner.invoke( + cli, ["delete", "--force", emoji_name, "-o", "json"] + ) + emoji_list = json.loads(result.stdout) + emoji = find_dict_in_list(emoji_list, "name", emoji_name) + assert result.exit_code == 0 + assert len(emoji_list) == 1 + assert emoji["name"] == emoji_name + + +@pytest.mark.vcr() +def test_force_delete_absent_emoji(cli_runner): + # Setup + emoji_name = "absent_emoji" + user = "user-1" + # Test + with user_env(user): + result = cli_runner.invoke( + cli, ["delete", "--force", emoji_name, "-o", "json"] + ) + assert result.exit_code == 0 + assert result.stdout == "" + + +@pytest.mark.vcr() +def test_interactive_delete_emoji(cli_runner): + # Setup + # 1st will be deleted + # 2nd will not be deleted + user = "user-1" + emoji_names = ["emoji_1", "emoji_2"] + emoji_paths = [] + for name in emoji_names: + emoji_paths.append(EMOJIS[name]) + create_emojis(emoji_names, user) + # Test + with user_env(user): + result = cli_runner.invoke( + cli, + ["delete", "--interactive", "-o", "json"] + emoji_paths, + input="yes\nno\n", + ) + assert result.exit_code == 0 + # Output contains the invocation input as well + emoji_list = json.loads(result.stdout.split("\n")[-2]) + assert len(emoji_list) == 1 + emoji1 = find_dict_in_list(emoji_list, "name", emoji_names[0]) + assert emoji1["name"] == emoji_names[0] + # Teardown + delete_emojis([emoji_names[1]], user) diff --git a/tests/utils.py b/tests/utils.py new file mode 100644 index 00000000..dbf97291 --- /dev/null +++ b/tests/utils.py @@ -0,0 +1,84 @@ +from unittest.mock import patch +from urllib.parse import urlparse + +from mattermostdriver import Driver as Mattermost + +API_URL = "http://localhost:8065/api/v4" +EMOJIS = { + "emoji_1": "tests/emojis/emoji_1.png", + "emoji_2": "tests/emojis/emoji_2.png", + "emoji_3": "tests/emojis/emoji_3.png", + "parentheses_spaced": "tests/emojis/parentheses (spaced).png", +} +USERS = { + "sysadmin": { + "username": "sysadmin", + "email": "sysadmin@sample.mattermost.com", + "password": "sysadmin", + }, + "user-1": { + "username": "user-1", + "email": "user-1@sample.mattermost.com", + "password": "user-1", + }, + "user-2": { + "username": "samuel.tucker", + "email": "user-2@sample.mattermost.com", + "password": "user-2", + }, +} + + +def find_dict_in_list(lst, key, value): + """Find a dict by key name inside a list""" + for dic in lst: + if dic[key] == value: + return dic + return None + + +def user_env(user): + """Patch env with user credentials""" + return patch.dict( + "os.environ", + { + "MM_URL": API_URL, + "MM_LOGIN_ID": USERS[user]["email"], + "MM_PASSWORD": USERS[user]["password"], + }, + ) + + +def authenticate(user): + """Authenticate against the Mattermost server""" + url = urlparse(API_URL) + settings = { + "scheme": url.scheme, + "url": url.hostname, + "port": url.port, + "basepath": url.path, + "login_id": USERS[user]["email"], + "password": USERS[user]["password"], + } + + mattermost = Mattermost(settings) + mattermost.login() + return mattermost + + +def create_emojis(emojis, user): + """Create emojis using a specific user""" + mattermost = authenticate(user) + for name in emojis: + with open(EMOJIS[name], "rb") as image: + mattermost.emoji.create_custom_emoji(name, {"image": image}) + mattermost.logout() + + +def delete_emojis(emojis, user): + """Delete emojis using a specific user""" + mattermost = authenticate(user) + for name in emojis: + emoji = mattermost.emoji.get_custom_emoji_by_name(name) + mattermost.emoji.delete_custom_emoji(emoji["id"]) + mattermost.logout()