Skip to content
Snippets Groups Projects
Commit 4866413c authored by Hatice Yildirim's avatar Hatice Yildirim
Browse files

Meine Implementierung converterr.py

parent 8ed541eb
No related branches found
No related tags found
2 merge requests!8Develop2,!5RafehDaniel
# You can override the included template(s) by including variable overrides
# SAST customization: https://docs.gitlab.com/ee/user/application_security/sast/#customizing-the-sast-settings
# Secret Detection customization: https://docs.gitlab.com/ee/user/application_security/secret_detection/pipeline/#customization
# Dependency Scanning customization: https://docs.gitlab.com/ee/user/application_security/dependency_scanning/#customizing-the-dependency-scanning-settings
# Container Scanning customization: https://docs.gitlab.com/ee/user/application_security/container_scanning/#customizing-the-container-scanning-settings
# Note that environment variables can be set in several places
# See https://docs.gitlab.com/ee/ci/variables/#cicd-variable-precedence
stages:
- test
sast:
stage: test
include:
- template: Security/SAST.gitlab-ci.yml
# Praxisprojekt Technologiebasierte Innovationen
## Getting started
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
## Add your files
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
```
cd existing_repo
git remote add origin https://gitlab.reutlingen-university.de/Daniel.Rafeh/praxisprojekt-technologiebasierte-innovationen.git
git branch -M main
git push -uf origin main
```
## Integrate with your tools
- [ ] [Set up project integrations](https://gitlab.reutlingen-university.de/Daniel.Rafeh/praxisprojekt-technologiebasierte-innovationen/-/settings/integrations)
## Collaborate with your team
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
## Test and Deploy
Use the built-in continuous integration in GitLab.
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
***
# Editing this README
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
## Name
Choose a self-explaining name for your project.
## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
## License
For open source projects, say how it is licensed.
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
File added
File added
# Bei Eingabe der Zahl 1 soll "I" ausgegeben werden
# Bei Eingabe der Zahl 2 soll "II" ausgegeben werden
# Bei Eingabe der Zahl 3 soll "III" ausgegeben werden
# Bei Eingabe der Zahl 4 soll "IV" ausgegeben werden
# Bei Eingabe der Zahl 5 soll "V" ausgegeben werden
# Bei Eingabe der Zahl 9 soll "IX" ausgegeben werden
# Bei Eingabe der Zahl 10 soll "X" ausgegeben werden
# Bei Eingabe der Zahl 21 soll "XXI" ausgegeben werden
# Bei Eingabe der Zahl 50 soll "L" ausgegeben werden
# Bei Eingabe der Zahl 100 soll "C" ausgegeben werden
# Bei Eingabe der Zahl 500 soll "D" ausgegeben werden
# Bei Eingabe der Zahl 1000 soll "M" ausgegeben werden
# Bei Eingabe der Zahl 1111 soll "MCXI" ausgegeben werden
# Bei Eingabe der Zahl 99 soll "XCIX" ausgegeben werden
# Bei Eingabe der Zahl 0 soll "Es gibt keine römische Null" ausgegeben werden
# Bei Eingabe der Zahl 40 soll "XL" ausgegeben werden
# Bei Eingabe eines Strings soll "Bitte ganze Zahlen eingeben" ausgegeben werden -> geändert aufgrund der Aufgabenstellung
# Bei Eingabe von Float-Werten (z.B. 4,3) soll "Bitte ganze Zahlen eingeben" ausgegeben werden.
# Bei Eingabe von negativen Werten (z.B. -5) soll "Es sind nur positive Zahlen zum konvertieren erlaubt" ausgegeben werden
# Bei Eingabe der Zahl 2025 soll "MMXXV" ausgegeben werden
# Bei Eingabe von Zeichen wie ! soll "Bitte ganze Zahlen eingeben" ausgegeben werden
# Bei Eingabe mehrerer Zahlen wie 4, 3 soll "Bitte nur eine ganze Zahl eingeben" augegeben werden
# Bei Eingabe größerer Zahlen wie z.B. 4000 soll "MMMM" ausgegeben werden
# Bei Eingabe der Zahl 30 soll "XXX" ausgegeben werden
# Bei Eingabe der Zahl 90 soll "90" ausgegeben werden
# Bei Eingabe eines leeren Strings soll "Bitte ganze Zahlen eingeben" ausgegeben werden
import unittest
from abc import ABC, abstractmethod
class IConverter(ABC):
@abstractmethod
def convert(self, num: int) -> str:
pass
class Converter(IConverter):
def convert(self, num: int) -> str:
'''Sicherstellen, dass nur eine ganze Zahl eingegeben wurde.'''
if isinstance(num, str) and len(num.split(',')) > 1:
return 'Bitte nur eine ganze Zahl eingeben'
roman_numbers = [(1000, 'M'), (500, 'D'), (100, 'C'), (90, 'XC'), (50, 'L'), (40, 'XL'), (10, 'X'), (9, 'IX'), (5, 'V'), (4, 'IV'), (1, 'I')]
roman_str = ''
'''Wenn eine 0 eingegeben wird muss eine Exception folgen'''
if num == 0:
return "Es gibt keine römische Null"
'''Sicherstellen, dass keine Zeichen oder Strings eingegeben werden'''
if isinstance(num, int):
'''Sicherstellen, dass keine negativen Zahlen eingegeben werden'''
if num < 0:
return "Es sind nur positive Zahlen zum konvertieren erlaubt"
for value, numeral in roman_numbers:
while num >= value:
roman_str += numeral
num -= value
return roman_str
else:
return "Bitte ganze Zahlen eingeben"
class TestConverter(unittest.TestCase):
def setUp(self):
self.c = Converter()
def test_convertOne(self):
res = self.c.convert(1)
self.assertEqual(res, 'I')
def test_convertTwo(self):
res = self.c.convert(2)
self.assertEqual(res, 'II')
def test_convertThree(self):
res = self.c.convert(3)
self.assertEqual(res, 'III')
def test_convertFour(self):
res = self.c.convert(4)
self.assertEqual(res, 'IV')
def test_convertFive(self):
res = self.c.convert(5)
self.assertEqual(res, 'V')
def test_convertNine(self):
res = self.c.convert(9)
self.assertEqual(res, 'IX')
def test_convertTen(self):
res = self.c.convert(10)
self.assertEqual(res, 'X')
def test_convertTwentyTwo(self):
res = self.c.convert(21)
self.assertEqual(res, 'XXI')
def test_convertFifty(self):
res = self.c.convert(50)
self.assertEqual(res, 'L')
def test_convertHundred(self):
res = self.c.convert(100)
self.assertEqual(res, 'C')
def test_convertFiveHundred(self):
res = self.c.convert(500)
self.assertEqual(res, 'D')
def test_convertThousand(self):
res = self.c.convert(1000)
self.assertEqual(res, 'M')
def test_convertFourDigit(self):
res = self.c.convert(1111)
self.assertEqual(res, 'MCXI')
def test_convertNintyNine(self):
res = self.c.convert(99)
self.assertEqual(res, 'XCIX')
def test_convertZero(self):
res = self.c.convert(0)
self.assertEqual(res, 'Es gibt keine römische Null')
def test_convertFourty(self):
res = self.c.convert(40)
self.assertEqual(res, 'XL')
def test_convertString(self):
res = self.c.convert('HUIHIN')
self.assertEqual(res, "Bitte ganze Zahlen eingeben")
def test_convertFloat(self):
res = self.c.convert(4.3)
self.assertEqual(res, "Bitte ganze Zahlen eingeben")
def test_convertNegative(self):
res = self.c.convert(-4)
self.assertEqual(res, "Es sind nur positive Zahlen zum konvertieren erlaubt")
def test_convertYear(self):
res = self.c.convert(2025)
self.assertEqual(res, "MMXXV")
def test_convertSign(self):
res = self.c.convert('!')
self.assertEqual(res, "Bitte ganze Zahlen eingeben")
def test_convertMultipleNum(self):
res = self.c.convert('4, 3')
self.assertEqual(res, "Bitte nur eine ganze Zahl eingeben")
def test_convertHighNum(self):
res = self.c.convert(4000)
self.assertEqual(res, "MMMM")
def test_convertThirty(self):
res = self.c.convert(30)
self.assertEqual(res, "XXX")
def test_convertNinety(self):
res = self.c.convert(90)
self.assertEqual(res, "XC")
def test_convertEmpty(self):
res = self.c.convert('')
self.assertEqual(res, "Bitte ganze Zahlen eingeben")
if __name__ == "__main__":
unittest.main()
#Umsetzungen von RafehDaniel auf meine Testfälle
import unittest
from converter import Converter as RomanNumber
from converter import Converter as IConverter
class TestRomanConverter(unittest.TestCase):
def setUp(self):
self.converter = RomanNumber()
def test_implements_interface(self):
self.assertIsInstance(self.converter, IConverter)
def test_single_value(self):
self.assertEqual(self.converter.convert(1), "I")
self.assertEqual(self.converter.convert(2), "II")
self.assertEqual(self.converter.convert(3), "III")
self.assertEqual(self.converter.convert(4), "IV")
self.assertEqual(self.converter.convert(5), "V")
self.assertEqual(self.converter.convert(9), "IX")
self.assertEqual(self.converter.convert(21), "XXI")
self.assertEqual(self.converter.convert(50), "L")
self.assertEqual(self.converter.convert(100), "C")
self.assertEqual(self.converter.convert(500), "D")
self.assertEqual(self.converter.convert(1000), "M")
def test_inivalid_numbers(self):
self.assertEqual(self.converter.convert(6), "")
self.assertEqual(self.converter.convert(99), "")
self.assertEqual(self.converter.convert(-1), "")
if __name__ == "__main__":
unittest.main()
import unittest
from converterr import RomanNumber
from converterr import IRomanNumber
class TestConverter(unittest.TestCase):
def setUp(self):
self.c = RomanNumber()
def test_implements_interface(self):
self.assertIsInstance(self.c, IRomanNumber)
def test_convertOne(self):
res = self.c.convert(1)
self.assertEqual(res, 'I')
def test_convertTwo(self):
res = self.c.convert(2)
self.assertEqual(res, 'II')
def test_convertThree(self):
res = self.c.convert(3)
self.assertEqual(res, 'III')
def test_convertFour(self):
res = self.c.convert(4)
self.assertEqual(res, 'IV')
def test_convertFive(self):
res = self.c.convert(5)
self.assertEqual(res, 'V')
def test_convertNine(self):
res = self.c.convert(9)
self.assertEqual(res, 'IX')
def test_convertTen(self):
res = self.c.convert(10)
self.assertEqual(res, 'X')
def test_convertTwentyTwo(self):
res = self.c.convert(21)
self.assertEqual(res, 'XXI')
def test_convertFifty(self):
res = self.c.convert(50)
self.assertEqual(res, 'L')
def test_convertHundred(self):
res = self.c.convert(100)
self.assertEqual(res, 'C')
def test_convertFiveHundred(self):
res = self.c.convert(500)
self.assertEqual(res, 'D')
def test_convertThousand(self):
res = self.c.convert(1000)
self.assertEqual(res, 'M')
def test_convertFourDigit(self):
res = self.c.convert(1111)
self.assertEqual(res, 'MCXI')
def test_convertNintyNine(self):
res = self.c.convert(99)
self.assertEqual(res, 'XCIX')
def test_convertZero(self):
res = self.c.convert(0)
self.assertEqual(res, 'Es gibt keine römische Null')
def test_convertFourty(self):
res = self.c.convert(40)
self.assertEqual(res, 'XL')
def test_convertString(self):
res = self.c.convert('HUIHIN')
self.assertEqual(res, "Bitte ganze Zahlen eingeben")
def test_convertFloat(self):
res = self.c.convert(4.3)
self.assertEqual(res, "Bitte ganze Zahlen eingeben")
def test_convertNegative(self):
res = self.c.convert(-4)
self.assertEqual(res, "Es sind nur positive Zahlen zum konvertieren erlaubt")
def test_convertYear(self):
res = self.c.convert(2025)
self.assertEqual(res, "MMXXV")
def test_convertSign(self):
res = self.c.convert('!')
self.assertEqual(res, "Bitte ganze Zahlen eingeben")
def test_convertMultipleNum(self):
res = self.c.convert('4, 3')
self.assertEqual(res, "Bitte nur eine ganze Zahl eingeben")
def test_convertHighNum(self):
res = self.c.convert(4000)
self.assertEqual(res, "MMMM")
def test_convertThirty(self):
res = self.c.convert(30)
self.assertEqual(res, "XXX")
def test_convertNinety(self):
res = self.c.convert(90)
self.assertEqual(res, "XC")
def test_convertEmpty(self):
res = self.c.convert('')
self.assertEqual(res, "Bitte ganze Zahlen eingeben")
if __name__ == "__main__":
unittest.main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment